Token from react native in django api

I am developing an application with a React Native application and a Django Rest Framework backend. Now, when users are authenticated in React Native, and I use the getCredentials() function from the useAuth0() hook, I get an accessToken and an idToken. However, both of these tokens are unable to authenticate in the Django REST framework application, returning the following:

{
“detail”: “Invalid token.”
}
I followed this tutorial to integrate Auth0 with django.
Maybe this has something to do with the fact that the Django api is registered as an API in Auth0 and that it has an identifier? Because this identifier is nowhere mentioned in the React native client.
Any help/insights are appreciated.

Hey there @txtdataigr welcome to the community!

In case you haven’t figured this out yet, I definitely think you were on the right track with this. In order for the API to validate the access token you pass to it, you’ll need to include an audience param in your call to webAuth:

auth0.webAuth
    .authorize({
      audience: 'https://api.yoursite.com',  // Replace with your API's audience value (identifier)
      scope: 'openid profile email'
    })

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.