Hi! I’m building a React-Native app (with Expo) and have a question regarding getting a token for multiple APIs (yes I read the docs :D).
I have my own api: https://api.mydomain.com/graphql
with scope admin:grapqhl-api
and I’m using the Auth0 Management API v2 (https://mytenant.eu.auth0.com/api/v2/
with scope update:current_user_metadata
).
How can I create a ‘combined’ api so I can get 1 accessToken that is valid for both APIs?
I’ve created a third API: https://api.mydomain.com/mobile-user
, added scopes admin:grapqhl-api
and update:current_user_metadata
but when I try to use the token this 3rd API returns to update user_metadata on the Management API, I get the error:
user_metadata Object {
"error": "Unauthorized",
"message": "Bad audience: https://api.mydomain.com/mobile-user https://mytenant.eu.auth0.com/userinfo",
"statusCode": 401,
}
This makes sense, because mobile-user
not /userinfo
are the API I’m talking to which is /api/v2/
.
My auth config:
Object {
"additionalParameters": Object {
"audience": "https://api.mydomain.com/mobile-user",
},
"clientId": "MYCLIENTID",
"issuer": "https://mytenant.eu.auth0.com",
"redirectUrl": "exp://127.0.0.1:19000/oauthredirect",
"scopes": Array [
"openid",
"profile",
"email",
"offline_access",
"update:current_user_metadata",
"admin:graphql-api",
],
}
If I use audience https://mytenant.eu.auth0.com/api/v2/
I get a perfectly functioning token, but this would only be valid for the Management API v2 not my own API.
How to solve this? Thanks in advance!
P.S. The idea is to have one token that allows me to update user details using user_metadata but also use it to talk to my backend graphql api.