# Can't get access token using Authorization Code Flow API

**URL:** <https://community.auth0.com/t/cant-get-access-token-using-authorization-code-flow-api/104646>\
**Category:** Get Help\
**Tags:** connection-provisioning-flows, connections\
**Created:** [April 13, 2023, 4:36pm UTC](https://community.auth0.com/t/cant-get-access-token-using-authorization-code-flow-api/104646 "2023-04-13T16:36:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pavlo.ignatenko](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@pavlo.ignatenko](https://community.auth0.com/u/pavlo.ignatenko)\
**Post date:** [April 13, 2023, 4:36pm UTC](https://community.auth0.com/t/cant-get-access-token-using-authorization-code-flow-api/104646/1 "2023-04-13T16:36:14Z")

</div>

Hi there!  
I’m trying to get a token using node’s https client.  
I follow the following guideline - [Call Your API Using the Authorization Code Flow](https://auth0.com/docs/get-started/authentication-and-authorization-flow/call-your-api-using-the-authorization-code-flow)

1. I make call to /authorize with params like that:  
method: ‘GET’,  
host: ‘[poc-hs1.us.auth0.com](http://poc-hs1.us.auth0.com)’,  
path: ‘/authorize?response\_type=code&client\_id=0AX0SJOUeExghDBBpZd4wIT9SNVBInqR&redirect\_uri=http%3A%2F%2Flocalhost%3A3002%2Fapi%2Fauth%2Fcallback&scope=openid+profile+email+offline\_access&audience=http%3A%2F%2Flocalhost%3A8080%2Fapi&state=1x2y3z4’,

I expect of getting url /callback?code=… as stated in the guideline, but it returns /login?state=…  
Type of the application - **Regular Web Application** , grant type - **authorization code**.  
P.s. with current application setup I can easily get an access token with **client\_credentials** and **password** grant types.

Thanks for assistance.

---

<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:** [April 13, 2023, 5:42pm UTC](https://community.auth0.com/t/cant-get-access-token-using-authorization-code-flow-api/104646/3 "2023-04-13T17:42:38Z")

</div>

Hi @pavlo.ignatenko,

Welcome to the Auth0 Community!

I understand that you need help with getting an access token with the Authorization Code grant flow.

Firstly, requesting the `/authorize` endpoint is the correct starting step to getting an access token.

Please note that the authorization code flow expects user interaction. Therefore, I recommend using a browser to get the `/authorize` endpoint:

```auto
https://poc-hs1.us.auth0.com/authorize?response_type=code&client_id=0AX0SJOUeExghDBBpZd4wIT9SNVBInqR&redirect_uri=http%3A%2F%2Flocalhost%3A3002%2Fapi%2Fauth%2Fcallback&scope=openid+profile+email+offline_access&audience=http%3A%2F%2Flocalhost%3A8080%2Fapi&state=1x2y3z4%E2%80%99

```

On this login page, it will prompt the user to enter their credentials to log in.

Only after successfully logging in will the browser return the code in the URL that looks something like the following:

```auto
https://https://poc-hs1.us.auth0.com/callback?code={authorizationCode}&state=1x2y3z4

```

I hope the explanation was clear.

Please let me know if you have any questions.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![pavlo.ignatenko](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@pavlo.ignatenko](https://community.auth0.com/u/pavlo.ignatenko)\
**Post date:** [April 13, 2023, 7:47pm UTC](https://community.auth0.com/t/cant-get-access-token-using-authorization-code-flow-api/104646/4 "2023-04-13T19:47:38Z")

</div>

Thanks a lot Rueben for such prompt response.  
We’re creating tests which communicate the backend service directly.  
Probably you could suggest another flow using user credentials but without interaction with browser, thru API only?  
Thanks in advance.

---

<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:** [April 14, 2023, 3:08am UTC](https://community.auth0.com/t/cant-get-access-token-using-authorization-code-flow-api/104646/5 "2023-04-14T03:08:53Z")

</div>

Hi @pavlo.ignatenko,

Thank you for your response.

> [@pavlo.ignatenko](#):
>
> We’re creating tests which communicate the backend service directly.  
> Probably you could suggest another flow using user credentials but without interaction with browser, thru API only?

In this situation, I recommend using the Client Credentials flow to get an access token without user interaction that grants access to your API.

See the [Call Your API Using the Client Credentials Flow](https://auth0.com/docs/get-started/authentication-and-authorization-flow/call-your-api-using-the-client-credentials-flow) documentation for more information.

Please let me know if you need further clarification on these instructions.

Thanks,  
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:** [April 28, 2023, 3:09am UTC](https://community.auth0.com/t/cant-get-access-token-using-authorization-code-flow-api/104646/6 "2023-04-28T03:09:10Z")

</div>

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