Payment Sky API 401 Error: Token Expired
Hi,
Yesterday we had an issue with BBMS transactions in our Spark website. About 10 transactions failed due to the refresh token expired. After I signed into BB and authorized the project to get a new refresh token (see Sky API Authorize screenshot), the issue was fixed.
We did have almost 2 months without a credit card donation. But according to the documentation (https://developer.blackbaud.com/skyapi/docs/authorization#token-expiration), refresh tokens will expire after 365 days. I wonder why our refresh token expired? The second screenshot shows the piece of code that caught the 401 error: Token Expired.
The initial access token and refresh token are saved in database. Each time we exchange our refresh token for a new access token, the old refresh token in the table is updated by the new refresh token. So it should never expire!
Thanks,
-Tiehu
Yesterday we had an issue with BBMS transactions in our Spark website. About 10 transactions failed due to the refresh token expired. After I signed into BB and authorized the project to get a new refresh token (see Sky API Authorize screenshot), the issue was fixed.
We did have almost 2 months without a credit card donation. But according to the documentation (https://developer.blackbaud.com/skyapi/docs/authorization#token-expiration), refresh tokens will expire after 365 days. I wonder why our refresh token expired? The second screenshot shows the piece of code that caught the 401 error: Token Expired.
The initial access token and refresh token are saved in database. Each time we exchange our refresh token for a new access token, the old refresh token in the table is updated by the new refresh token. So it should never expire!
Thanks,
-Tiehu
1
Comments
-
Hi Tiehu,
This is Chris from the SKY API team.
You are correct about the lifespan of SKY API refresh tokens -- 365 days. I can actually see a few metrics for your app indicating a decent number of refresh tokens dating back to last year (you can private message me if you want more details about that).
I believe the code snippet you included in your post is from the actual Payments API request, correct? That 401 would indicate that the access token is not valid (likely expired). For refresh token exchanges to the SKY API OAuth 2 `/token` endpoint, an expired (or invalid) refresh token error would be indicated by a 400 (BadRequest) response with "invalid_grant" indicated in by the body. Read more about possible token exchange errors here
Still, it's entirely possible that your refresh token became invalid due to some other exchange issue. I've written a few posts in the past about how you can make that exchange more resilient. In any case, I think the most important point is to have some logging around refresh token exchange failures and to account for unexpected responses from our OAuth service (a 400 or -the hopefully never, rare - 500 response).
Feel free to reach out to me if you have more questions (or private message if there are specific about your app that you need to discuss).0
Categories
- All Categories
- 6 Blackbaud Community Help
- 211 bbcon®
- 1.4K Blackbaud Altru®
- 402 Blackbaud Award Management™ and Blackbaud Stewardship Management™
- 1.1K Blackbaud CRM™ and Blackbaud Internet Solutions™
- 15 donorCentrics®
- 360 Blackbaud eTapestry®
- 2.6K Blackbaud Financial Edge NXT®
- 655 Blackbaud Grantmaking™
- 576 Blackbaud Education Management Solutions for Higher Education
- 3.2K Blackbaud Education Management Solutions for K-12 Schools
- 941 Blackbaud Luminate Online® and Blackbaud TeamRaiser®
- 84 JustGiving® from Blackbaud®
- 6.7K Blackbaud Raiser's Edge NXT®
- 3.7K SKY Developer
- 248 ResearchPoint™
- 120 Blackbaud Tuition Management™
- 165 Organizational Best Practices
- 240 Member Lounge (Just for Fun)
- 34 Blackbaud Community Challenges
- 37 PowerUp Challenges
- 3 (Open) PowerUp Challenge: Grid View Batch
- 3 (Closed) PowerUp Challenge: Chat for Blackbaud AI
- 3 (Closed) PowerUp Challenge: Data Health
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Product Update Briefing
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Standard Reports+
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Email Marketing
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Gift Management
- 4 (Closed) Raiser's Edge NXT PowerUp Challenge: Event Management
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Home Page
- 4 (Closed) Raiser's Edge NXT PowerUp Challenge: Standard Reports
- 4 (Closed) Raiser's Edge NXT PowerUp Challenge: Query
- 796 Community News
- 3K Jobs Board
- 54 Blackbaud SKY® Reporting Announcements
- 47 Blackbaud CRM Higher Ed Product Advisory Group (HE PAG)
- 19 Blackbaud CRM Product Advisory Group (BBCRM PAG)

