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"
]
I want to add details in the JACKSON MOURA code snippet with an explanation.
In settings.py, you have to do this. I didn't find any good documentation. But it works for social authentication. now you don't need to set up the social auth apps by using the admin panel anymore. I showed samples of Google, Facebook, and LinkedIn. It will work with other social apps as well.
Now in view.py, you have to create serializer classes. all will be the same. I am showing for Google, LinkedIn, and Facebook.
Now, the backend is ready for getting post data from the frontend and will show perfect error like below. It will work with all other social apps.