Call an API - Consent required

I am having the same issue. Using React.

I have logged my user out of the app, and re logged in.

I read this thread and followed this documentation. Also this tutorial which is broken and makes no mention of a consent screen for accessing the Management API.

This code causes the “Consent required” error:

const accessToken = await getAccessTokenSilently({
  audience: "https://localhost:22522",
  scope: "read:test",
});

I have created a custom API in Auth0 with audience “https://localhost:22522” and created the “read:test” permissions also.

All I want is to have the user login and then test getting an access token from Auth0, I don’t want to have another popup giving authorization to access things as that is not up to the user. This would be an API for basic functionality of the app. Authentication should imply authorization in this case.


EDIT: passing in the audience and scope to the Auth0Provider component seems to be sufficient. We do not need to then pass it in again to getAccessTokenSilently(). That may be incorrect but I tested it and seem to have a value that looks like a JWT.

This worked:

<Auth0Provider
            domain={domain}
            clientId={clientId}
            redirectUri={window.location.origin}
            onRedirectCallback={onRedirectCallback}
            audient={audience}
            scope={scope}
        >
            <App/>
        </Auth0Provider>

Then later to get an access token:

    const accessToken = await getAccessTokenSilently();
    console.log(accessToken);

I seem to get a long value that looks like a long encoded string, which I can only assume is an opaque token.


If this is correct could you please adjust your documentation? Just… like in general coz it’s pretty terrible, but also specifically with relation to this issue. Thx.

4 Likes