Skip to content
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

Support Access Token Refresh for MSAL Provided Tokens (with_interactive, with_device_flow, with_client_certificate) #953

Merged
merged 1 commit into from
Apr 4, 2025

Conversation

kamilkrukowski
Copy link
Contributor

PR Description

This PR addresses re-addresses issue #950, which still occurs in the latest 2.6.1 release.

It extends the token refresh behavior to support MSAL-based authentication workflows — specifically with_client_certificate, with_interactive, and with_device_flow — by incorporating token expiration and refresh logic whenever using a cached access token.


Comment

In reviewing the current implementation:

  • TokenResponse does not have an explicitly annotated expiresIn property.
  • However, the constructor methods in AuthenticationContext — including with_interactive, with_device_flow, and with_client_certificate — all rely on MSAL, which consistently returns an expires_in field in its token response.
  • The TokenResponse class dynamically sets this field when available.

To ensure compatibility while maintaining backward safety, this PR takes a conservative approach: it checks for the presence of the expiresIn attribute on TokenResponse before using it, and gracefully defaults to the original behavior if it's absent.

@vgrem vgrem merged commit 8b889d9 into vgrem:master Apr 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants