Skip to content

Commit 622f251

Browse files
committed
chore: get is_legacy_token from request
1 parent b559c35 commit 622f251

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

oauth2_provider/oauth2_validators.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -480,20 +480,16 @@ def save_bearer_token(self, token, request, *args, **kwargs):
480480

481481
# Users on older app versions should get long-lived tokens for
482482
# backwards compatibility.
483-
is_legacy_token = request.POST.get('is_legacy_token', False)
483+
is_legacy_token = getattr(request, 'is_legacy_token', False)
484484

485485
if is_legacy_token:
486-
access_token_expire_seconds = (
487-
settings.LEGACY_ACCESS_TOKEN_EXPIRE_SECONDS,
488-
)
486+
expire_seconds = oauth2_settings.LEGACY_ACCESS_TOKEN_EXPIRE_SECONDS
489487
else:
490-
access_token_expire_seconds = app.access_token_expire_seconds
488+
expire_seconds = app.access_token_expire_seconds
491489

492490
# expires_in is passed to Server on initialization
493491
# custom server class can have logic to override this
494-
expires = (
495-
timezone.now() + timedelta(seconds=access_token_expire_seconds)
496-
)
492+
expires = timezone.now() + timedelta(seconds=expire_seconds)
497493

498494
if request.grant_type == "client_credentials":
499495
request.user = None

0 commit comments

Comments
 (0)