3
votes

I'm using django-rest-auth for social auth via API. I've configured Facebook and it works perfectly but I've got some issues with Google social auth.

  1. I've added to INSTALLED_APPS:
allauth.socialaccount.providers.google',
  1. Created views:

from allauth.socialaccount.providers.google.views import GoogleOAuth2Adapter
from allauth.socialaccount.providers.oauth2.client import OAuth2Client

class CustomGoogleOAuth2Adapter(GoogleOAuth2Adapter):
    basic_auth = False


class GoogleLogin(SocialLoginView):
    adapter_class = CustomGoogleOAuth2Adapter
    client_class = OAuth2Client
  1. Created app by admin panel
  2. I've got access_token from https://developers.google.com/oauthplayground/
  3. When I tried to log in by endpoint I got an error:
Reverse for 'redirect' not found. 'redirect' is not a valid view function or pattern name.
1
Is that the whole of your views.py file?Demetris
check if this is of any help to you stackoverflow.com/a/48182227/2560466statelessprotocol
@Ernst share your root urls.pyanjaneyulubatta505
I also using access_token, and I didn't setup the callback url.aijogja

1 Answers

3
votes

It's hard to pin point the error since you did not include the rest of your codes. The error simply means it cannot find the url with name 'redirect'. So there are 2 things you can check:

urlpatterns = [
    ...,
    url(r'^rest-auth/', include('rest_auth.urls'))
]

Under “APIs & auth” go to “Credentials” and create a new Client ID. Probably you will want a “Web application” Client ID. Provide your domain name or test domain name in “Authorized JavaScript origins”. Finally fill in http://127.0.0.1:8000/accounts/google/login/callback/ in the “Authorized redirect URI” field. You can fill multiple URLs, one for each test domain. After creating the Client ID you will find all details for the Django configuration on this page.