API Tokens - React Native SDK

Hello Folks,

I have managed to get a react native app working with the SDK available here - https://github.com/auth0/react-native-auth0

Able to login and get the ‘accessToken’ just fine. After that, able to get user details via ‘userInfo’. So far so good.

Now, this react native app is a sibling app to a single page web app that is already running just fine. The single page web app is able to

a) Login
b) Talk to the API.

The react native app should also do the same thing.

a) Login - working no problem.
b) Talk to the API - Having trouble here.

In the single page web app, I see a very convenient function, like this.

// Get the access token from the Auth0 client
const token = await auth0.getTokenSilently();

So, I assumed that there would be a similar token getting operation here on react native library too, that will allow me to login and quickly jump to accessing my API. I have a spent a ton of time looking at the https://github.com/auth0/react-native-auth0 documentation but no mention of anything can be give me something as simple as the above mentioned getTokenSilently.

So, ultimately, I just want to access my API, so how do I get my API Token? I feel like I am missing something very obvious here.

Its alright folks. I solved it.


      scope: 'openid profile email',
      audience:'copy paste audience URL from settings of API here'
    {ephemeralSession: true}

I had to add the audience.

1 Like

Glad you have figured it out and thanks for sharing with the rest of community!

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