Regarding the InvalidTokenError: Invalid Compact JWS
error many are experiencing.
I spent a couple hours trying to figure out this same problem. There are many posts in the forum suggesting to add the audience
param to the <Auth0Provider/>
component in React-Native. This does not work.
After digging deep into the useAuth0()
hook package and types, I found that you can pass the audience
param to the authorize()
call when initiating the login flow:
await authorize({
audience: 'SAME-AUDIENCE-AS-IN-API',
});
That worked for me, and now I’m getting a valid JWT which validates on the API side. You can get your token this way:
const credentials = await getCredentials();
console.log(credentials?.accessToken);
I’m not sure why this is not anywhere in the docs, but I would like to understand why the other often suggestion solution does not work, and why this one works, and if indeed I can safely keep using this method.
Thanks