# How to get the access token and id token using react-auth0-spa?

**URL:** <https://community.auth0.com/t/how-to-get-the-access-token-and-id-token-using-react-auth0-spa/39254>\
**Category:** Get Help\
**Tags:** auth0js\
**Created:** [March 12, 2020, 6:25am UTC](https://community.auth0.com/t/how-to-get-the-access-token-and-id-token-using-react-auth0-spa/39254 "2020-03-12T06:25:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohd.ilyas](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mohd.ilyas/32/15641_2.png) [@mohd.ilyas](https://community.auth0.com/u/mohd.ilyas)\
**Post date:** [March 12, 2020, 6:25am UTC](https://community.auth0.com/t/how-to-get-the-access-token-and-id-token-using-react-auth0-spa/39254/1 "2020-03-12T06:25:19Z")

</div>

Hi

I am trying to integrate React with Auth0 and I am using the functions provided by **react-auth0-spa.js**.  
In this, there is a function **loginWithRedirect** that redirects a user to Auth0 universal login page if the user hasn’t authenticated before.

Once there is a callback from Auth0, it is handled by another function:

```
 const handleRedirectCallback = async () => {
    setLoading(true);
    await auth0Client.handleRedirectCallback();
    const user = await auth0Client.getUser();
    setLoading(false);
    setIsAuthenticated(true);
    setUser(user);
  };

```

At this point, I want the user profile as well as the **access token** and **id token**. How can I do that?  
I could see browser making an API call for the token.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [March 12, 2020, 3:13pm UTC](https://community.auth0.com/t/how-to-get-the-access-token-and-id-token-using-react-auth0-spa/39254/3 "2020-03-12T15:13:16Z")

</div>

Hi @mohd.ilyas,

Have you looked through our [react quickstart](https://auth0.com/docs/quickstart/spa/react/01-login)? It demonstrates how to get userinfo and an access token. To get the id token you can use the function described [here](http://community.auth0.com/t/how-do-i-get-my-access-token/30904/12).

If you have trouble let me know and we can walk through it.

Thanks,  
Dan

---

<div class="post-metadata">

**Author:** ![mohd.ilyas](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mohd.ilyas/32/15641_2.png) [@mohd.ilyas](https://community.auth0.com/u/mohd.ilyas)\
**Post date:** [March 13, 2020, 4:57am UTC](https://community.auth0.com/t/how-to-get-the-access-token-and-id-token-using-react-auth0-spa/39254/4 "2020-03-13T04:57:04Z")

</div>

Hi @dan.woda thanks for your response.

I am already aware of getting an access token and id token. Whenever a user logs in with Auth0, there are HTTP calls for /authorize followed by call for oauth/token and in the response of oauth/token, we get access token, id token. I wanted to know if that response is available to us via react-auth0-spa?

thanks

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [March 16, 2020, 4:39pm UTC](https://community.auth0.com/t/how-to-get-the-access-token-and-id-token-using-react-auth0-spa/39254/5 "2020-03-16T16:39:38Z")

</div>

I’m not sure I understand your question. Did you look at the quickstart?

---

<div class="post-metadata">

**Author:** ![mohd.ilyas](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mohd.ilyas/32/15641_2.png) [@mohd.ilyas](https://community.auth0.com/u/mohd.ilyas)\
**Post date:** [March 17, 2020, 3:31am UTC](https://community.auth0.com/t/how-to-get-the-access-token-and-id-token-using-react-auth0-spa/39254/6 "2020-03-17T03:31:52Z")

</div>

Hi @dan.woda

I was able to get the id and access token.I used getTokenSilently() to get access token and getIDTokenClaims() to get id token.

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [March 17, 2020, 9:11pm UTC](https://community.auth0.com/t/how-to-get-the-access-token-and-id-token-using-react-auth0-spa/39254/7 "2020-03-17T21:11:37Z")

</div>

Great! Let me know if you have any more questions.

Dan

---

<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:** [July 13, 2020, 10:15pm UTC](https://community.auth0.com/t/how-to-get-the-access-token-and-id-token-using-react-auth0-spa/39254/8 "2020-07-13T22:15:46Z")

</div>

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