sperfecto
sperfecto

Reputation: 33

Django/React Native/OAuth: Best way to handle Auth flow?

So I'm trying to integrate a Django/Python backend framework with a React Native frontend, and I was wondering if there are any good resources/answers out there to handle OAuth flow?

I've tried a lot of different aspects, and from the server side at least, the best thing that possibly worked is OAuth Toolkit. I also want to use Django REST framework to exchange data between server/client.

However, I am confused about the flow of authentication between the app and the server and would appreciate a better understanding. Thanks!

Upvotes: 1

Views: 1977

Answers (1)

ezchen
ezchen

Reputation: 41

The Django OAuth Toolkit documentation has a good tutorial on how to get started:

OAuth Toolkit Tutorial

A basic summary of the authentication flow:

  • Login with credentials (Post request to server with username/password)
  • Server returns an auth token to React-Native client application to use. You should store this somehow in the react-native app, such as a cookie
  • When performing an API request, provide the token in the request header like so:
    • Authorization: "Bearer TOKEN_VALUE_RETURNED_FROM_SERVER"

Upvotes: 3

Related Questions