Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions rest_framework_social_oauth2/oauth2_grants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import time

try:
from django.urls import reverse
Expand Down Expand Up @@ -90,6 +91,11 @@ def validate_token_request(self, request):

try:
user = backend.do_auth(access_token=request.token)
user_data = backend.user_data(access_token=request.token)
exp = user_data['exp']

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the value exp holds?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exp is the expiration date of the token

if exp is not None and exp <= int(time.time()):
raise errors.InvalidTokenError('Token has expired', request=request)

except requests.HTTPError as e:
raise errors.InvalidRequestError(
description="Backend responded with HTTP{0}: {1}.".format(e.response.status_code,
Expand Down