Sporadic 401 errors getting a constituent or titles, or posting a constituent
constituent/v1/titles
or posting a constituent at
constituent/v1/constituents
or other constituent work like getting aliases or searching for a constituent by ID.
Occasionally we'll get reports from the field that something doesn't work correctly in the app, the Titles won't populate the dropdown, or the constituent search fails, etc. The error we get in a lot of these cases is a 401. Sometimes it seems like there might be network issues or other things going on, but I've never seen any evidence that a 401 can be caused by network issues. So for the 401s specifically - is this our refresh token expiring before we have allowed for that? I'm not the developer, we have an external agency, I'm just trying to help troubleshoot things. I've not got any good way of knowing when our token is being refreshed in each case. Also - if the same user account is logged in to 2 devices, will that mess with the refresh token between devices at all?
Happy to provide more detail if that helps - didn't want to go overboard with detail in the first instance. Thanks to anyone who has any insight!
Dev
Comments
-
Hi Dev Lunsford, typically the 401 error with, "The required Authorization header was missing or invalid, or the token has expired" message is normal and just means the access token has expired and will need to be refreshed. I don't believe that particular error is due to an expired refresh token or the refresh token being invalid. The SKY API authorization docs goes into some detail on how to respond to the "401 Not Authorized" error by refreshing the token.
Although less likely since the app is making successful requests, the 401 error could also mean that the token supplied in the Authorization header is invalid due to being malformed. It's worth checking on that also just to make sure nothings going wrong sometimes when populating the header.
Also with each refresh, a new refresh token will be returned as described in the SKY API auth common issues documentation. That does mean that if you use a refresh token to refresh an access token that you'll need to store the new refresh token to refresh the subsequent access token, and so on... If you've burned the refresh token once (say the user logged into one device refreshes) and then try to use the same refresh token again (same user on a separate device) then you may receive a different error (invalid_grant).
Hope that helps!2 -
Another thing to evaluate is whether you're having a race condition where multiple requests happen in parallel to refresh an expired token. We introduced the preserve_refresh_token option described here to help with that type of scenario:
https://developer.blackbaud.com/skyapi/docs/authorization/auth-code-flow/tutorial#refresh-access-token1 -
Thanks Michael & Ben, this is useful. I'm going to pass this on to our developer in case it can help shed any light on what's happening.
Can a header get accidentally malformed by bad network conditions, or is that not really possible?
Presumably this could mean that the 401s we see in the error logging (Sentry.io) may in some circumstances literally just be the notification that the token needs to be refreshed now - and at that point the app would ideally nip over and refresh the token and then retry the last operation? It's possible this is already what it does, in which case 401's not a problem - it's just that we are also getting reports of odd behaviour at times and it looked like this might be a cause. It's quite possible that's something else. In any case, this should help us with what to look at next. Thanks again!
Dev1
Categories
- All Categories
- 6 Blackbaud Community Help
- 213 bbcon®
- 1.4K Blackbaud Altru®
- 403 Blackbaud Award Management™ and Blackbaud Stewardship Management™
- 1.2K Blackbaud CRM™ and Blackbaud Internet Solutions™
- 15 donorCentrics®
- 360 Blackbaud eTapestry®
- 2.6K Blackbaud Financial Edge NXT®
- 656 Blackbaud Grantmaking™
- 577 Blackbaud Education Management Solutions for Higher Education
- 3.2K Blackbaud Education Management Solutions for K-12 Schools
- 940 Blackbaud Luminate Online® and Blackbaud TeamRaiser®
- 84 JustGiving® from Blackbaud®
- 6.7K Blackbaud Raiser's Edge NXT®
- 3.7K SKY Developer
- 249 ResearchPoint™
- 119 Blackbaud Tuition Management™
- 165 Organizational Best Practices
- 241 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)


