Skip to content

Commit 8e85d41

Browse files
committed
fix: check access token expiry only if exists
1 parent 622f251 commit 8e85d41

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

oauth2_provider/models.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,11 +396,15 @@ def is_expired(self):
396396
now = timezone.now()
397397
is_refresh_token_expired = now >= expires
398398

399+
# Access token assumed to be expired, by default.
400+
is_access_token_expired = True
401+
399402
# RefreshToken should not outlive AccessToken.
400403
# NOTE: Check AccessToken expiration for backwards compatibility with
401404
# long-lived tokens.
402-
access_token_expires = self.access_token.expires
403-
is_access_token_expired = now >= access_token_expires
405+
if self.access_token:
406+
access_token_expires = self.access_token.expires
407+
is_access_token_expired = now >= access_token_expires
404408

405409
# RefreshToken expired if and only if both refresh and access tokens
406410
# are expired.

0 commit comments

Comments
 (0)