# getCredentials usage react native sdk

**URL:** <https://community.auth0.com/t/getcredentials-usage-react-native-sdk/186210>\
**Category:** Get Help\
**Tags:** mfa-prompt-new-experience, mfa\
**Created:** [May 1, 2025, 5:53pm UTC](https://community.auth0.com/t/getcredentials-usage-react-native-sdk/186210 "2025-05-01T17:53:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jerembardon](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jerembardon/32/74565_2.png) [@jerembardon](https://community.auth0.com/u/jerembardon)\
**Post date:** [May 1, 2025, 5:53pm UTC](https://community.auth0.com/t/getcredentials-usage-react-native-sdk/186210/1 "2025-05-01T17:53:42Z")

</div>

Hello,

I have successfully implemented the auth0 biometric flow with Webauthn and token rotation using the react-native-auth0.

Currently I use the provider for authorize user to connect. After that I would like to use the getCredentials method **outside** a react component.

I use this code in my middleware:

```auto
const baseQuery = fetchBaseQuery({
  timeout: 12000,
  prepareHeaders: async headers => {
    const userAgent = UserAgent.getUserAgent();

    const credentials = await auth0Instance.credentialsManager.getCredentials(
      AUTH0_SCOPE,
      AUTH0_TOKEN_MIN_TLL,
    );

    if (credentials.accessToken) {
      headers.set('Authorization', `Bearer ${credentials.accessToken}`);
    }

    headers.set('Accept', 'application/json');
    headers.set('User-Agent', userAgent);

    return headers;
  },
});

```

The problem is that auth0Instance is not the instance created by the Auth0Provider. Is there any solution to use the function `getCredentials` use by the provider outside a react component ? Or should I consider another strategy to refresh the token, if so waht could be this strategy ?

I use the version 4 SDK

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [May 5, 2025, 11:48pm UTC](https://community.auth0.com/t/getcredentials-usage-react-native-sdk/186210/3 "2025-05-05T23:48:39Z")

</div>

Hi @jerembardon,

Welcome to the Auth0 Community!

The `getCredentials` method is the correct approach here to get the access token.

In this case, you might need to export an instance of your `Auth0Client` for use outside of a React component.

I hope this helps!

Let me know if you have any questions.

Thank you,  
Rueben

---

<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:** [May 19, 2025, 11:49pm UTC](https://community.auth0.com/t/getcredentials-usage-react-native-sdk/186210/4 "2025-05-19T23:49:00Z")

</div>

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