# How to do authorisation code flow programmatically?

**URL:** <https://community.auth0.com/t/how-to-do-authorisation-code-flow-programmatically/61497>\
**Category:** Get Help\
**Created:** [April 21, 2021, 3:39pm UTC](https://community.auth0.com/t/how-to-do-authorisation-code-flow-programmatically/61497 "2021-04-21T15:39:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hugh.livingstone](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/hugh.livingstone/32/28936_2.png) [@hugh.livingstone](https://community.auth0.com/u/hugh.livingstone)\
**Post date:** [April 21, 2021, 3:39pm UTC](https://community.auth0.com/t/how-to-do-authorisation-code-flow-programmatically/61497/1 "2021-04-21T15:39:15Z")

</div>

Hi,

We are trying to find a way of doing the authorisation code flow without having to open a browser window and enter the credentials in the login page. We want to be able to do this for our automated tests.

I was hoping there was an endpoint we could send a request to and get a code returned but i could not find anything like that in the docs.

There is an endpoint exposed to retrieve a token but we want the front end to only ever see the code so this flow is preferable.

if its not possible then we will use selenium etc to grab what we need.

Thanks for your help!

---

<div class="post-metadata">

**Author:** ![ricardo.batista](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ricardo.batista/32/7711_2.png) [@ricardo.batista](https://community.auth0.com/u/ricardo.batista)\
**Post date:** [April 29, 2021, 6:58am UTC](https://community.auth0.com/t/how-to-do-authorisation-code-flow-programmatically/61497/2 "2021-04-29T06:58:03Z")

</div>

Hi @hugh.livingstone

The authorization code flow is a redirect flow that always relies on the user interaction. If you’re trying to automate testing in the backend, the best option is to create a user account for your software and use the Resource Owner Password Credentials Grant, as shown here:

> **[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.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [April 29, 2021, 10:03am UTC](https://community.auth0.com/t/how-to-do-authorisation-code-flow-programmatically/61497/3 "2021-04-29T10:03:58Z")

</div>

Thanks for helping on this one Ricardo!

---

<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 14, 2021, 10:04am UTC](https://community.auth0.com/t/how-to-do-authorisation-code-flow-programmatically/61497/4 "2021-05-14T10:04:37Z")

</div>

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