Skip to content

Commit e612c17

Browse files
dulmandakhauvipy
authored andcommitted
default expires in _create_authorization_code
1 parent 558fb78 commit e612c17

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

oauth2_provider/oauth2_validators.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -446,9 +446,7 @@ def get_code_challenge_method(self, code, request):
446446
return grant.code_challenge_method or None
447447

448448
def save_authorization_code(self, client_id, code, request, *args, **kwargs):
449-
expires = timezone.now() + timedelta(
450-
seconds=oauth2_settings.AUTHORIZATION_CODE_EXPIRE_SECONDS)
451-
self._create_authorization_code(request, code, expires)
449+
self._create_authorization_code(request, code)
452450

453451
def rotate_refresh_token(self, request):
454452
"""
@@ -563,7 +561,10 @@ def _create_access_token(self, expires, request, token, source_refresh_token=Non
563561
source_refresh_token=source_refresh_token,
564562
)
565563

566-
def _create_authorization_code(self, request, code, expires):
564+
def _create_authorization_code(self, request, code, expires=None):
565+
if not expires:
566+
expires = timezone.now() + timedelta(seconds=oauth2_settings.AUTHORIZATION_CODE_EXPIRE_SECONDS)
567+
567568
return Grant.objects.create(
568569
application=request.client,
569570
user=request.user,

0 commit comments

Comments
 (0)