How to access token after signin with google dj_rest_auth

Viewed 29

When I visit this url https://accounts.google.com/o/oauth2/v2/auth?redirect_uri=<CALLBACK_URL_YOU_SET_ON_GOOGLE>&prompt=consent&response_type=token&client_id=&scope=openid%20email%20profile

it redirect to me http://127.0.0.1:8000/accounts/google/login/callback/#access_token=tokonkey&token_type=Bearer&expires_in=3599&scope=email%20profile%20https://www.googleapis.com/auth/userinfo.profile%20openid%20https://www.googleapis.com/auth/userinfo.email&authuser=0&prompt=consent

in response I got

"success"

But I want to get access_token that shown in url,just like

{

"token":tokenkey

}

can someone tell me how to do that?

And my code look likes

In urls.py

from users.views import  GoogleLogin,GoogleRedirect
path('auth/google/', GoogleLogin.as_view(), name='google_login'),
path('accounts/google/login/callback/', GoogleRedirect.as_view())

in views.y

class GoogleLogin(SocialLoginView):
    adapter_class = GoogleOAuth2Adapter
    client_class = OAuth2Client
    
class GoogleRedirect(APIView):
    def get(self, request):
       
        return Response("success")
'''
0 Answers
Related