Skip to content

Conversation

@bendavis78
Copy link
Contributor

@bendavis78 bendavis78 commented Nov 25, 2025

This fixes issue #841 - OAuth2Token should use expires_in provided alongside unparsable expires_at

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. (N/A - this is a backward-compatible bugfix)

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

Fixes #841

When expires_at cannot be parsed as an integer, fall back to using
expires_in to calculate expiration. This maintains backward compatibility
where expires_at takes precedence when both parameters are present and
valid, while gracefully handling the case where expires_at is unparseable.

Changes:
- Fall back to expires_in if expires_at is unparseable
- Add isinstance check in is_expired() for non-integer expires_at
- Preserve unparseable expires_at values in the token dict

Fixes authlib#841
@lepture lepture merged commit 260d04e into authlib:main Nov 27, 2025
8 checks passed
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

2 participants