Facebook login/registration: Error validating verification code

406 Views Asked by At

I am using django-rest-auth which uses django-allauth for social logins. I set login for facebook according the rest-auth documentation. This is a view. Authentication works, but the email for the user was empty. So I add callback_url and client_class (like documentation said).

from rest_auth.registration.views import SocialLoginView
from allauth.socialaccount.providers.oauth2.client import OAuth2Client


class FacebookLogin(SocialLoginView):
    adapter_class = FacebookOAuth2Adapter
    callback_url = 'http://localhost:8000/rest-auth/facebook/'
    client_class = OAuth2Client

But it is not working. It returns this error:

Error validating verification code. Please make sure your redirect_uri is identical to the one you used in the OAuth dialog request

First I think the problem is in the library. So I printed out all parameters for the request and I check all these things. Everything looks fine, so I tried to put the URL with these parameters to Facebook Graph API. But the error is the same. Here is the all URL which I tried manually, without using the allauth library:

https://graph.facebook.com/v2.10/oauth/access_token?redirect_uri=http://localhost:8000/rest-auth/facebook/&client_id=203192345223034931&client_secret=a475bbbscds65437c89bf04d359d98a&code=203192345223034931|l3ujbbbscdhrf0404d3B2de57Dw

cliend_id and client_secret I took from Facebook developers console from Dashboard. And the code is App Token from here

In the facebook developers interface I set:

Valid OAuth redirect URIs: http://localhost:8000/rest-auth/facebook/

App domains: localhost

Because I tried it manually in my browser I hope it won't be a problem with libraries but with my settings or my misunderstanding of something.

I tried it with the normal domain, but it has not come any change.

0

There are 0 best solutions below