React + React Native + Django AllAuth

I'm running a Django server which has API's I consume through a React Native and React applications.

I want it to work for Google, Facebook, Instagram and Twitter.

For this question I want to focus on the React Application and Google Authentication and hopefully it will be repeatable for my other social options.

My React Application manages to login just fine for Google

It returns field called "credentials" which appears to be JWT.

My thinking was I can send this whole JWT or decode it and send the JTI value to Django AllAuth, which would call google and then return user data, which I can create a Django User and sign in and if that user already has an account it just login and return user data to my React Server.

Some features on the API require users to have loggedin.

I have the same client_id for my React and Django app.

Does AllAuth do this already ? How do I work with it?

When I try forward my 'credentials' (the one google returned to my React) to

auth/google/

I get a 403.

I would imagine I don't have to do this pragmatically as this seems like a pretty common setup .

Any guidance on how I can make these React and Django AllAuth work together would be great.

I assume you are using Django REST for your APIs. If so, there are excellent third-party packages that simplifies registration and authentication such as dj-rest-auth. It provides Drop-in API endpoints for handling authentication securely in Django Rest Framework and works well with React. Whether you are using Custom User Model and/or allauth, dj-rest-auth integrates well with both.

Вернуться на верх