# React Native - Refresh token not working

**URL:** <https://community.auth0.com/t/react-native-refresh-token-not-working/7999>\
**Category:** Get Help\
**Tags:** react-native, refresh-tokens\
**Created:** [August 28, 2017, 8:12pm UTC](https://community.auth0.com/t/react-native-refresh-token-not-working/7999 "2017-08-28T20:12:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![AashishKumar](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@AashishKumar](https://community.auth0.com/u/AashishKumar)\
**Post date:** [August 28, 2017, 8:12pm UTC](https://community.auth0.com/t/react-native-refresh-token-not-working/7999/1 "2017-08-28T20:12:53Z")

</div>

```
import Auth0 from 'react-native-auth0';
const auth0 = new Auth0(credentials);
getToken = (authData) => {
    auth0
      .auth
      .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"
}

```

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [August 29, 2017, 2:54pm UTC](https://community.auth0.com/t/react-native-refresh-token-not-working/7999/2 "2017-08-29T14:54:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![AashishKumar](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@AashishKumar](https://community.auth0.com/u/AashishKumar)\
**Post date:** [August 29, 2017, 3:11pm UTC](https://community.auth0.com/t/react-native-refresh-token-not-working/7999/3 "2017-08-29T15:11:53Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [September 7, 2017, 6:44pm UTC](https://community.auth0.com/t/react-native-refresh-token-not-working/7999/4 "2017-09-07T18:44:06Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 2, 2018, 5:56am UTC](https://community.auth0.com/t/react-native-refresh-token-not-working/7999/5 "2018-03-02T05:56:11Z")

</div>


