Repository navigation
feat: add AuthServerUnavailableError for discovery and JWKS fetch failures - #148
Merged
Merged
Conversation
nandan-bhat
reviewed
Oct 23, 2026
Discovery and JWKS fetch failures raise AuthServerUnavailableError only for connection errors, timeouts, HTTP 5xx and HTTP 429. Other failures keep raising VerifyAccessTokenError.
nandan-bhat
approved these changes
Oct 23, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📋 Changes
This PR adds
AuthServerUnavailableError, raised when the OIDC discovery document or the JWKS cannot be reached while verifying an access token. Callers can now tell an outage on the authorization server side apart from a token that was rejected, so a good token is not reported as invalid.✨ Features
AuthServerUnavailableErrorsubclassesVerifyAccessTokenError, with status503and error codeauth_server_unavailable. Existingexcept VerifyAccessTokenErrorhandlers still catch it.verify_request()sets noWWW-Authenticateheader on this error, so clients retry later instead of requesting a new token.verify_access_token()andverify_request()(Bearer and DPoP) raise the new error.🔧 API Changes
AuthServerUnavailableErrorfrom the package root.5xxor429response) now raisesAuthServerUnavailableErrorwith status503. It previously raisedVerifyAccessTokenErrorwith status401. Other fetch failures, such as a404or a malformed response, still raiseVerifyAccessTokenError.500or above no longer get aWWW-Authenticateheader fromverify_request().Raisessections ofverify_request(),verify_access_token(),get_access_token_for_connection()andget_token_on_behalf_of().📖 Documentation
README.mdto describe the new error under "Verify the Access Token"EXAMPLES.mddocs/MultipleCustomDomain.md🧪 Testing
Contributor Checklist