Skip to content

Bubble up refresh exception when we cannot recover #434

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion msal/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,9 @@ def _acquire_token_silent_from_cache_and_possibly_refresh_it(
if (result and "error" not in result) or (not access_token_from_cache):
return result
except: # The exact HTTP exception is transportation-layer dependent
logger.exception("Refresh token failed") # Potential AAD outage?
# Typically network error. Potential AAD outage?
if not access_token_from_cache: # It means there is no fall back option
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is possible for access_token_from_cache to be not-None here? It seems L1198 will prevent a not-None access_token_from_cache to reach here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 1198 would be skipped by line 1196. So, this check here is still beneficial.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. Even if AT_AGING refresh fails, access_token_from_cache can serve as a fallback. Thanks for the explanation.

raise # We choose to bubble up the exception
return access_token_from_cache

def _acquire_token_silent_by_finding_rt_belongs_to_me_or_my_family(
Expand Down