# Auth Token not working

**URL:** <https://community.auth0.com/t/auth-token-not-working/78202>\
**Category:** Get Help\
**Created:** [February 13, 2022, 10:39pm UTC](https://community.auth0.com/t/auth-token-not-working/78202 "2022-02-13T22:39:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wrftaylor](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/wrftaylor/32/35184_2.png) [@wrftaylor](https://community.auth0.com/u/wrftaylor)\
**Post date:** [February 13, 2022, 10:39pm UTC](https://community.auth0.com/t/auth-token-not-working/78202/1 "2022-02-13T22:39:01Z")

</div>

Similar to `[How do I get an auth token](https://community.auth0.com/t/how-do-i-get-an-auth-token-using-postman-instead-of-the-browser/69226)`

In my ruby app, I have:

```auto
url = URI('https://quicky.eu.auth0.com/authorize?response_type=code&'\
'client_id=REMOVED&redirect_uri=http://localhost:'\
'3002/auth/auth0/callback&scope=SCOPE&audience=editable-api&state=STATE')

    http = Net::HTTP.new(url.host, url.port)
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_NONE

    request = Net::HTTP::Get.new(url)

```

this returns a 302 response, where the body is simply:

```auto
Found. Redirecting to /u/login?state=hKFo2SBEMU5CY... (etc)

```

According to [the documentation](https://auth0.com/docs/get-started/authentication-and-authorization-flow/call-your-api-using-the-authorization-code-flow), I should instead be getting:

```auto
HTTP/1.1 302 Found
Location: http://localhost:3002/auth/auth0/callback?code=AUTHORIZATION_CODE&state=xyzABC123

```

Now when I instead enter the `https://quicky.eu.auth0.com/authorize` URI above into the browser, it does correctly respond with [http://localhost:3002/auth/auth0/callback?code=CORRECT\_CODE&state=STATE](http://localhost:3002/auth/auth0/callback?code=CORRECT_CODE&state=STATE), although it raises a CSRF response.

How can I get this to work from inside the server instead of via the browser?

---

<div class="post-metadata">

**Author:** ![markd](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/markd/32/38919_2.png) [@markd](https://community.auth0.com/u/markd)\
**Post date:** [February 14, 2022, 5:34pm UTC](https://community.auth0.com/t/auth-token-not-working/78202/2 "2022-02-14T17:34:16Z")

</div>

Hello @wrftaylor. `response_type=code` implies you are using the [authorization code](https://auth0.com/docs/get-started/authentication-and-authorization-flow/authorization-code-flow) flow, which means you are logging in as a user. If you want to do this without user interaction you need to use the [client credentials](https://auth0.com/docs/get-started/authentication-and-authorization-flow/client-credentials-flow) flow instead which allows for machine-to-machine communications without user interaction.

---

<div class="post-metadata">

**Author:** ![wrftaylor](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/wrftaylor/32/35184_2.png) [@wrftaylor](https://community.auth0.com/u/wrftaylor)\
**Post date:** [February 15, 2022, 7:54am UTC](https://community.auth0.com/t/auth-token-not-working/78202/3 "2022-02-15T07:54:48Z")

</div>

Thanks markd! Ok, that’s clarifying.

---

<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:** [February 15, 2022, 11:25am UTC](https://community.auth0.com/t/auth-token-not-working/78202/4 "2022-02-15T11:25:08Z")

</div>

Teamwork makes the dreamwork!

---

<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:** [February 22, 2022, 2:33pm UTC](https://community.auth0.com/t/auth-token-not-working/78202/5 "2022-02-22T14:33:51Z")

</div>


