K
Kinde6mo ago
Daniel237

No audience for token in react native

I am having an issue where I am trying to create a token for a microservice of mine, and that microserivce checks for the audience of incoming requests, since I use it for a web app as well. And I cannot find a way to have the audience set in the access token obtained by the react native app. I am using expo, const client = new KindeSDK( process.env.KINDE_ISSUER_URL!, process.env.KINDE_POST_CALLBACK_URL!, process.env.KINDE_CLIENT_ID!, process.env.KINDE_POST_LOGOUT_REDIRECT_URL!, undefined, { audience: "http://localhost:5010", } ); The undefined there is the scope, since I haven't set those up yet. I mention that I have set up the API's in the Kinde dashboard and everything, so I don't really know where the issue is coming from. Did someone face this or can anyone help me with it?
9 Replies
Claire_Kinde
Claire_Kinde6mo ago
Hi Daniel. Here's a few troubleshooting tips. Give them a shot and let me know how you go. 1. ​API Registration in Kinde Dashboard​: Ensure that your API is correctly registered in the Kinde dashboard and that the audience value matches exactly what you are using in your code. 2. ​Scope Parameter​: Even though you mentioned that you haven't set up the scopes yet, it's a good practice to define them. The default scopes are profile, email, offline, and openid. You can set them as follows:
const client = new KindeSDK( process.env.KINDE_ISSUER_URL!, process.env.KINDE_POST_CALLBACK_URL!, process.env.KINDE_CLIENT_ID!, process.env.KINDE_POST_LOGOUT_REDIRECT_URL!, "profile email offline openid", { audience: "http://localhost:5010/" } );
3. ​Audience URL​: Ensure that the audience URL you are using (http://localhost:5010/) is exactly the same as the one registered in the Kinde dashboard. 4. ​Token Verification​: Verify the token you receive to ensure that the audience claim is present. You can use tools like jwt.io to decode and inspect the token. 5. ​Environment Variables​: Make sure that all the environment variables (KINDE_ISSUER_URL, KINDE_POST_CALLBACK_URL, KINDE_CLIENT_ID, KINDE_POST_LOGOUT_REDIRECT_URL) are correctly set and accessible in your environment. If you have verified all the above and there's still an issue, let us know. Claire
Daniel237
Daniel237OP6mo ago
I did all the steps and there is still no audience claim
Claire_Kinde
Claire_Kinde6mo ago
I'll ask a team member to have a look. Hey there. Our React/Expo team member is off until Tuesday next week UK time. Can the issue wait or is it a blocker?
Daniel237
Daniel237OP6mo ago
It is a blocker, but it can wait.
Daniel_Kinde
Daniel_Kinde5mo ago
Hi @Daniel237 , Thank you for your patience here, I have been looking into this and I think may have found the cause. There is a workaround however. The login method take a parameter where you can pass in the audience
login({
audience: "URL"
})
login({
audience: "URL"
})
I will look at sorting the KindeSDK constructer param
Daniel237
Daniel237OP5mo ago
Ok, this seems to work but for one audience only, how can I set it up for multiple audiences at once?
Daniel_Kinde
Daniel_Kinde5mo ago
I can check, but I believe you can separate the audiences by a space.
Daniel237
Daniel237OP5mo ago
Tried spaces but does not work, the audience becomes blank
Daniel_Kinde
Daniel_Kinde5mo ago
Could you send me the full URL for the auth request to Kinde or HAR file please?
Want results from more Discord servers?
Add your server