mirror of
https://github.com/TurTaskProject/TurTaskWeb.git
synced 2025-12-19 05:54:07 +01:00
23 lines
924 B
Python
23 lines
924 B
Python
from allauth.socialaccount.providers.google.views import GoogleOAuth2Adapter
|
|
from allauth.socialaccount.providers.oauth2.client import OAuth2Error
|
|
import jwt
|
|
|
|
|
|
class CustomGoogleOAuth2Adapter(GoogleOAuth2Adapter):
|
|
def complete_login(self, request, app, token, response, **kwargs):
|
|
try:
|
|
identity_data = jwt.decode(
|
|
response["id_token"], #another nested id_token was returned
|
|
options={
|
|
"verify_signature": False,
|
|
"verify_iss": True,
|
|
"verify_aud": True,
|
|
"verify_exp": True,
|
|
},
|
|
issuer=self.id_token_issuer,
|
|
audience=app.client_id,
|
|
)
|
|
except jwt.PyJWTError as e:
|
|
raise OAuth2Error("Invalid id_token") from e
|
|
login = self.get_provider().sociallogin_from_response(request, identity_data)
|
|
return login |