File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
src/auth0_server_python/auth_server Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -615,13 +615,17 @@ async def get_access_token(
615615 if ts .get ("audience" ) == audience and (not scope or ts .get ("scope" ) == scope ):
616616 token_set = ts
617617 break
618- elif ts .get ("audience" ) != audience and not self ._use_mrrt :
619- # We have a token but for a different audience but since MRRT is disabled,
620- # we cannot use the RT to get a new AT for this audience
621- raise AccessTokenError (
622- AccessTokenErrorCode .INCORRECT_AUDIENCE ,
623- "The access token for the requested audience is not available and Multi-Resource Refresh Tokens are disabled."
624- )
618+ if ts .get ("audience" ) == audience and (not scope or ts .get ("scope" ) == scope ):
619+ token_set = ts
620+ break
621+
622+ # After loop: if no matching token found and MRRT disabled, check if we need to error
623+ if not token_set and not self ._use_mrrt and state_data_dict .get ("token_sets" ):
624+ # We have tokens but none match, and we can't use RT to get a new one
625+ raise AccessTokenError (
626+ AccessTokenErrorCode .INCORRECT_AUDIENCE ,
627+ "The access token for the requested audience is not available and Multi-Resource Refresh Tokens are disabled."
628+ )
625629
626630 # If token is valid, return it
627631 if token_set and token_set .get ("expires_at" , 0 ) > time .time ():
You can’t perform that action at this time.
0 commit comments