Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google authentication using django-rest-auth and allauth

I am trying to create an authentication API for a flutter app that will log users in with a google authentication signup/login form. I followed this tutorial to achieve this.

So far so good, except that the tutorial is based on a GitHub sign in rather than Google. I managed to get it working up till step "connecting" step. I am able to get the code from the redirect but when I access http://127.0.0.1:8000/auth/google/ I see it's asking for a two fields (access_token, code). When I try to just post with the information I do have I get the following error:

 "non_field_errors": [
        "View is not defined, pass it as a context variable"
]

enter image description here

like image 718
Marco Fernandes Avatar asked Oct 04 '20 12:10

Marco Fernandes


People also ask

How do I add Google login to Django project?

In many developer websites, we get to see Google social authentication which is very handy. In this article, we will see how to create a Django Google login project. First, go to https://console.cloud.google.com/apis/dashboardand create a project . Go to Oauth consent screen and create a screen and save & continue.


1 Answers

This is a version conflict error with djangorestframework => 3.12 Solution: Downgrade to djangorestframework <= 3.11.0 and everything should be fine.

like image 175
Williams Olawale Avatar answered Sep 22 '22 06:09

Williams Olawale