Skip to content

Fix: Handle unparseable expires_at by falling back to expires_in#840

Closed
ShaikAyesha17 wants to merge 1 commit intoauthlib:mainfrom
ShaikAyesha17:fix-expires-at-fallback-833
Closed

Fix: Handle unparseable expires_at by falling back to expires_in#840
ShaikAyesha17 wants to merge 1 commit intoauthlib:mainfrom
ShaikAyesha17:fix-expires-at-fallback-833

Conversation

@ShaikAyesha17
Copy link

Fixes #833

When an OAuth2/OIDC server returns expires_at as a string that cannot be parsed as an integer, the OAuth2Token initialization now gracefully handles the ValueError/TypeError and falls back to using expires_in to calculate the expiration time.

This prevents token creation from failing when expires_at is in a non-standard format while expires_in is available.

What kind of change does this PR introduce?

Does this PR introduce a breaking change?

Checklist

  • The commits follow the conventional commits specification.
  • You ran the linters with prek.
  • You wrote unit test to demonstrate the bug you are fixing, or to stress the feature you are bringing.
  • You reached 100% of code coverage on the code you edited, without abusive use of pragma: no cover
  • If this PR is about a new feature, or a behavior change, you have updated the documentation accordingly.

  • You consent that the copyright of your pull request source code belongs to Authlib's author.

Fixes authlib#833

When an OAuth2/OIDC server returns expires_at as a string that cannot be parsed as an integer, the OAuth2Token initialization now gracefully handles the ValueError/TypeError and falls back to using expires_in to calculate the expiration time.

This prevents token creation from failing when expires_at is in a non-standard format while expires_in is available.
@bendavis78
Copy link
Contributor

I have a PR w/ proper formatting, tests, etc here: #842

@azmeuk azmeuk closed this Nov 27, 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.

expires_in should be used instead of expires_at if expires_at cannot be parsed

3 participants