Empty Payload when calling getAccessTokenSilently

Hello, I’m getting an empty payload in the token returned from getAccessTokenSilently.

I am setting the audience parameter and have confirmed its value as well as the value for scope.

Can someone help me understand what’s going wrong? Below is the code.

Thank You!

useEffect(() => {
(async () => {
try {
const token = await getAccessTokenSilently({
authorizationParams: {
audience: ‘https://api.shawnapp.systems/’,
scope: ‘openid profile email offline_access’,
}
});

            const response = await fetch('https://shawnprod.shawn.auth0.com/userinfo', {
                headers: {
                Authorization: `Bearer ${token}`,
                },
            });
            setPosts(await response.json());
        } 
        catch (e) {
            console.error(e);
        }
    })();
}, [getAccessTokenSilently]);
1 Like

Hey there @skfabc welcome to the community!

What does the access token look like when decoded at jwt.io? Is the audience param you’re passing the exact same as the API identifier listed under the API registered in Auth0?

Keep us posted!

Hi, @tyf ,

I’ve confirmed that the audience param I’m passing is exactly the same as in Auth0. I DM’ed you the access token screen in jwt.io.

Thanks!

I am also facing exact same issue with react18, react-router-6 and “@auth0/auth0-react”: “^2.2.1”

I am passing audience too

1 Like

UPDATE: The issue I was having was due to the way we’d configured Auth0 between two different tenants. Not a coding issue.

1 Like

Hey @skfabc thanks for the update! Glad you were able to get this sorted :pray:

Hey there @bagulm123 ! Are you still experiencing the same issue? If so, I recommend opening a new topic with as much detail as you can provide.

Thanks!

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