# To get access token instead of code and state after authentication

**URL:** <https://community.auth0.com/t/to-get-access-token-instead-of-code-and-state-after-authentication/43559>\
**Category:** Get Help\
**Created:** [May 25, 2020, 7:02am UTC](https://community.auth0.com/t/to-get-access-token-instead-of-code-and-state-after-authentication/43559 "2020-05-25T07:02:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shikharrastogi36](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/shikharrastogi36/32/13031_2.png) [@shikharrastogi36](https://community.auth0.com/u/shikharrastogi36)\
**Post date:** [May 25, 2020, 7:02am UTC](https://community.auth0.com/t/to-get-access-token-instead-of-code-and-state-after-authentication/43559/1 "2020-05-25T07:02:35Z")

</div>

Sir, I’m using auth0 authentication for my app and I’ve set custom callback domain, but now I’m getting code instead of access token. So please send me any solution how can I get access token back instead of code and state

---

<div class="post-metadata">

**Author:** ![sidharth.chaudhary](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sidharth.chaudhary/32/20686_2.png) [@sidharth.chaudhary](https://community.auth0.com/u/sidharth.chaudhary)\
**Post date:** [May 25, 2020, 7:16am UTC](https://community.auth0.com/t/to-get-access-token-instead-of-code-and-state-after-authentication/43559/2 "2020-05-25T07:16:46Z")

</div>

Hello @shikharrastogi36

Welcome to the Auth0 Community!

The reason you are getting code in the callback is because of the type of authorization flow you are using  
In your application, please find below various authentication and authorization flows which Auth0 supports:

> **[Authentication and Authorization Flows](https://auth0.com/docs/get-started/authentication-and-authorization-flow)**
>
> Learn about the various flows used for authentication and authorization of applications and APIs.

In case you need directly the access token instead of the code, you need to use Implicit grant type as your Authentication and authorization flow. I suggest to have a look at the below documentation which details how you can Implement the Implicit grant type:

> **[Implicit Flow with Form Post](https://auth0.com/docs/get-started/authentication-and-authorization-flow/implicit-flow-with-form-post)**
>
> Learn how the Implicit flow with Form Post works and why you should use it for traditional web apps that need only an ID Token to perform user authentication.

Also it will be good to have a read to this link to understand which flow you should use based on your  
Application and use case:

> **[Which OAuth 2.0 Flow Should I Use?](https://auth0.com/docs/get-started/authentication-and-authorization-flow/which-oauth-2-0-flow-should-i-use)**
>
> Learn how to identify the proper OAuth 2.0 flow for your use case.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![tmilar.p](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/tmilar.p/32/29630_2.png) [@tmilar.p](https://community.auth0.com/u/tmilar.p)\
**Post date:** [May 26, 2021, 9:54pm UTC](https://community.auth0.com/t/to-get-access-token-instead-of-code-and-state-after-authentication/43559/3 "2021-05-26T21:54:09Z")

</div>

I started to have the same issue.  
I have created an auth0 Application “Single Page Application”.

But after authenticating with Auth0, the response to my `/callback` endpoint is sending `state` and `code` params, instead of the expected `access_token`, `id_token`, `expires`, and more.

I have checked the Grant Types configuration, and I have all of these are properly checked:

- Implicit
- Authorization Code
- Refresh Token

The documentation says this should be enough, but since the /callback request is not receiving the proper data, the callback to `auth0Client.parseHash(callback)` is resolving with `null` error and `null` authResult params.

Any ideas please?

---

<div class="post-metadata">

**Author:** ![robbierochaus](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/robbierochaus/32/41372_2.png) [@robbierochaus](https://community.auth0.com/u/robbierochaus)\
**Post date:** [January 1, 2023, 7:29pm UTC](https://community.auth0.com/t/to-get-access-token-instead-of-code-and-state-after-authentication/43559/4 "2023-01-01T19:29:06Z")

</div>

This solution does not seem to work in my React app, I am not using Node Express. I am deploying to Apache after I compile my code, do I need to set up Apache to accept the authorization? I am really confused, and would really prefer to use the Single Sign-On, it was simple to set up. Why does that not work? Why does the URL have the code and state variables anyway? Is there a way to remove that? It seems fine with local development, but, once I deploy it to Apache it does not work. I have five sites that are down because I can’t get this to work with my React app.
