Auth0 Home Blog Docs

React app failed retrieving user data with status code 403

I’m trying to get user info through my React app. I’m using auth0-lock and jwt-decode. Doesn’t seem to get the user info though.

this.lock = new Auth0Lock(
    AUTH_CONFIG.clientId,
    AUTH_CONFIG.domain,
    {
        allowedConnections: ['google-oauth2'],
        auth             : {
            redirectUrl : AUTH_CONFIG.callbackUrl,
            responseType: 'token id_token',
            audience    : `https://${AUTH_CONFIG.domain}/api/v2/`,
            params      : {
                scope: 'openid profile email'
            }
        }
    }
);

This is where the error comes out from:

getUserData = () => {
    return new Promise((resolve, reject) => {

        const tokenData = this.getTokenData();
        const {sub: userId} = tokenData;
        console.log(userId);
        const auth0UserUrl = 'https://' + AUTH_CONFIG.domain + '/api/v2/users/' + userId;

        axios.get(auth0UserUrl, {
            headers: {
                'Content-Type' : 'application/json',
                'Authorization': 'Bearer ' + this.getAccessToken()
            }
        }).then(response => {
            resolve(response.data);
        }).catch(error => {
            // handle error
            console.warn('Cannot retrieve user data', error); // It fires off here.
            reject(error);
        });
    });
};

It gives me “Cannot retrieve user data Error: Request failed with status code 403”. How can I get more information about this? What am I doing wrong?