Skip to content

Commit bbbc824

Browse files
committed
Merge branch 'FGI-1573_connected-account-support' of github.com:auth0/auth0-server-python into FGI-1573_connected-account-support
2 parents 3fecdbb + c09d803 commit bbbc824

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/auth0_server_python/auth_server/server_client.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff 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():

0 commit comments

Comments
 (0)