# How do you get user info when using the class based react native API?

**URL:** <https://community.auth0.com/t/how-do-you-get-user-info-when-using-the-class-based-react-native-api/134861>\
**Category:** Get Help\
**Tags:** user-profile, user-management\
**Created:** [May 23, 2024, 5:54pm UTC](https://community.auth0.com/t/how-do-you-get-user-info-when-using-the-class-based-react-native-api/134861 "2024-05-23T17:54:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hearhere](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@hearhere](https://community.auth0.com/u/hearhere)\
**Post date:** [May 23, 2024, 5:54pm UTC](https://community.auth0.com/t/how-do-you-get-user-info-when-using-the-class-based-react-native-api/134861/1 "2024-05-23T17:54:40Z")

</div>

Hello!

I’m using the class version of the React Native Auth0 package which is documented sparingly, so I’ve been struggling a bit.

I’ve set up and an Auth0 class instance with:

```auto
const auth0 = new Auth0({
        audience: config.audience,
        clientId: config.clientId,
        domain: config.domain,
    })

```

and am able to authorize with:

```auto
auth0.webAuth.authorize().then(credentials => {
            console.log("AUTHORIZED WITH: ", credentials)
})

```

That gives me what looks like a valid token – though trying to use it via CURL does not succeed, so it is possible I’m missing something already.

But what prompted me to post is this: Given the Auth0 class as created, how do you get out the logged in user’s information (givenName, familyName, email, etc)? I found this page of documentation: [Auth | react-native-auth0](https://auth0.github.io/react-native-auth0/classes/Types.Auth.html#userInfo)  
Which implied to me that this should work:  
`const userInfo = await auth0.userInfo()`  
as it’s a method returning a promise, however I actually see `TypeError: auth0.userInfo is not a function (it is undefined).`

How does one get this information out in this paradigm?

In case it’s relevant, the reason I’m doing this is because MobX and Hooks do not play well together.

Thanks!

---

<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 29, 2024, 8:52pm UTC](https://community.auth0.com/t/how-do-you-get-user-info-when-using-the-class-based-react-native-api/134861/3 "2024-05-29T20:52:26Z")

</div>

Hi @hearhere,

Welcome to the Auth0 Community!

> [@hearhere](#):
>
> That gives me what looks like a valid token – though trying to use it via CURL does not succeed, so it is possible I’m missing something already.

When you received your access token, have you had the chance to decode it? Say with a JWT library or on [jwt.io](http://jwt.io)?

> [@hearhere](#):
>
> Which implied to me that this should work:  
> `const userInfo = await auth0.userInfo()`  
> as it’s a method returning a promise, however I actually see `TypeError: auth0.userInfo is not a function (it is undefined).`

You will need to include the class and method in your code.

For example:  
`const userInfo = await auth0.auth.userInfo({ token: string })`

Could you give that a try and let me know how it goes for you?

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![hearhere](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@hearhere](https://community.auth0.com/u/hearhere)\
**Post date:** [June 11, 2024, 7:41pm UTC](https://community.auth0.com/t/how-do-you-get-user-info-when-using-the-class-based-react-native-api/134861/4 "2024-06-11T19:41:26Z")

</div>

In the days between your post and my reply I ended up refactoring my code to no longer use the class based method. I created a custom hook that generates my headers using the getCredentials hook from useAuth0() and import that hook everywhere I need to make network requests and pass my headers along to my data store.

I’m not going to re-refactor my code to confirm whether this does or does not work, but I hope it does help someone else.

---

<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:** [June 12, 2024, 12:20am UTC](https://community.auth0.com/t/how-do-you-get-user-info-when-using-the-class-based-react-native-api/134861/5 "2024-06-12T00:20:54Z")

</div>

Hi @hearhere,

Thanks for sharing your workaround!

I’m sure it will be useful to someone else in the Community. 👏

Let us know if you have any other questions.

Cheers,  
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:** [June 26, 2024, 12:21am UTC](https://community.auth0.com/t/how-do-you-get-user-info-when-using-the-class-based-react-native-api/134861/6 "2024-06-26T00:21:42Z")

</div>

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