auth0-samples / auth0-react-native-sample

Auth0 Integration Samples for React Native
https://auth0.com/docs/quickstart/native/react-native
MIT License
128 stars 156 forks source link

example for calling an api #51

Closed lutzk closed 3 years ago

lutzk commented 3 years ago

hello

in auth0-spa-js to get a token for a different audience i can use getTokenSilently with my target audience of the api i want to authenticate

is there a way to get a token for different audience silently with that auth0-react-native?

i checked the docs and src but i am not sure how to do that here in auth0-react-native using webAuth.authorize always opens the webview

Widcket commented 3 years ago

Hi @lutzk, it is not possible to get a token for a different audience without logging in again.

If you are passing the /userinfo endpoint as the audience on initial login and then attempting to use your own API as audience? Because if that’s the case, Auth0 always includes the /userinfo endpoint as the default audience value; there’s no need to specify it directly, and you could just pass your own API as the audience value on initial login.

Result: you would get a token with 2 audience values: /userinfo and your own API. That is the only possible case of multiple audience values supported by Auth0.

See https://auth0.com/docs/tokens/access-tokens/get-access-tokens#multiple-audiences