React Native - Refresh token not working

import Auth0 from 'react-native-auth0';
const auth0 = new Auth0(credentials);
getToken = (authData) => {
      .refreshToken({refreshToken: authData.refreshToken})
      .then(credentials => {console.log(credentials); return credentials.idToken})
      .catch(err => {console.log(err)});

This gives error:

    "error": "access_denied",
    "error_description": "Cannot read property 'audience' of undefined"

The combination of an access_denied error with a description that points to a Javascript error is, most of the times, associated with a custom rules error. In particular, a rule that performed the wrong assumption and was implemented correctly working for one scenario, but then fails for another.

For example, rules will have access to different context properties depending on how it was triggered. The recommendation would be for you to review your rules looking for any usage of an audience property in an object that may not be available for a refresh token grant.

1 Like

Thats was an awesome reply. I do run custom rule to enrich id_token with some scopes for different audiences. It seems the context doesn’t has audience defined as a property when token is getting refreshed. Any ideas on how to figure out the audience in this scenario. Or I should rethink how I embed custom scopes?

That would indeed explain the error; in relation to your use case I would have to check what would be the available options if any and then get back to you (I’ll be offline the next weeks so it may take some time).