# "403: Forbidden" returned by /oauth/token

**URL:** <https://community.auth0.com/t/403-forbidden-returned-by-oauth-token/75568>\
**Category:** Get Help\
**Created:** [December 29, 2021, 3:04am UTC](https://community.auth0.com/t/403-forbidden-returned-by-oauth-token/75568 "2021-12-29T03:04:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![skot](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/skot/32/33281_2.png) [@skot](https://community.auth0.com/u/skot)\
**Post date:** [December 29, 2021, 3:04am UTC](https://community.auth0.com/t/403-forbidden-returned-by-oauth-token/75568/1 "2021-12-29T03:04:27Z")

</div>

I’m using the right credentials as far as I can tell, but /oauth/token is returning 403. Anyone know how to troubleshoot this?

I’m following the instructions at

> **[Auth0 Authentication | Cypress Documentation](https://docs.cypress.io/guides/end-to-end-testing/auth0-authentication)**
>
> What you'll learn

Here’s what Cypress reports (secrets redacted with “xxx”):

The request we sent was:

Method: POST  
URL: [https://dev-rr9aqzra.us.auth0.com/oauth/token](https://dev-rr9aqzra.us.auth0.com/oauth/token)  
Headers: {  
“Connection”: “keep-alive”,  
“user-agent”: “Mozilla/5.0 (Macintosh; Intel Mac OS X 10\_15\_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36”,  
“accept”: “/”,  
“accept-encoding”: “gzip, deflate”,  
“content-type”: “application/json”,  
“content-length”: 264  
}  
Body: {“grant\_type”:“password”,“username”:“xxx”,“password”:“xxx”,“audience”:“[https://dev-rr9aqzra.us.auth0.com/api/v2/",“client\_id”:“xxx”,“client\_secret”:"xxx](https://dev-rr9aqzra.us.auth0.com/api/v2/%22,%22client_id%22:%22xxx%22,%22client_secret%22:%22xxx)”}

* * *

The response we got was:

Status: 403 - Forbidden  
Headers: {  
“date”: “Wed, 29 Dec 2021 02:58:40 GMT”,  
“content-type”: “application/json”,  
“transfer-encoding”: “chunked”,  
“connection”: “keep-alive”,  
“cf-ray”: “6c4fc4980dd632fa-EWR”,  
“cache-control”: “private, no-store, no-cache, must-revalidate, post-check=0, pre-check=0, no-transform”,  
“set-cookie”: [  
“did=s%3Av0%3A39b091d0-6853-11ec-a952-1f69958ecbc6.73sp%2BLVZU8NkrJ9VF2ofQoTj1p3hLn7xFlzW5Qj0FGA; Max-Age=31557600; Path=/; Expires=Thu, 29 Dec 2022 08:58:40 GMT; HttpOnly; Secure; SameSite=None”,  
“did\_compat=s%3Av0%3A39b091d0-6853-11ec-a952-1f69958ecbc6.73sp%2BLVZU8NkrJ9VF2ofQoTj1p3hLn7xFlzW5Qj0FGA; Max-Age=31557600; Path=/; Expires=Thu, 29 Dec 2022 08:58:40 GMT; HttpOnly; Secure”  
],  
“strict-transport-security”: “max-age=31536000”,  
“vary”: “Accept-Encoding, Origin”,  
“cf-cache-status”: “DYNAMIC”,  
“expect-ct”: “max-age=604800, report-uri=“[https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct](https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct)””,  
“ot-baggage-auth0-request-id”: “6c4fc4980dd632fa”,  
“ot-tracer-sampled”: “true”,  
“ot-tracer-spanid”: “33a90f300a6b65c4”,  
“ot-tracer-traceid”: “734a6576272b2ca1”,  
“x-auth0-requestid”: “75d76217265dd20ca3dc”,  
“x-content-type-options”: “nosniff”,  
“x-ratelimit-limit”: “30”,  
“x-ratelimit-remaining”: “29”,  
“x-ratelimit-reset”: “1640746721”,  
“server”: “cloudflare”,  
“alt-svc”: “h3=”:443"; ma=86400, h3-29=“:443”; ma=86400, h3-28=“:443”; ma=86400, h3-27=“:443”; ma=86400"  
}  
Body: {  
“error”: “access\_denied”,  
“error\_description”: “Unauthorized”  
}

---

<div class="post-metadata">

**Author:** ![James.Morrison](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/james.morrison/32/13507_2.png) [@James.Morrison](https://community.auth0.com/u/James.Morrison)\
**Post date:** [December 29, 2021, 6:49pm UTC](https://community.auth0.com/t/403-forbidden-returned-by-oauth-token/75568/2 "2021-12-29T18:49:17Z")

</div>

Hi there @skot 👋

We need to take a deeper look at what’s going on here. When you get a chance can you snag us a HAR capture of the event occurring and send that paired with the tenant name in a direct message over to myself & @rueben.tiow in the same message? Thanks in advance!

> **[Generate and Analyze HAR Files](https://auth0.com/docs/troubleshoot/troubleshooting-tools/generate-and-analyze-har-files)**
>
> Learn how to troubleshoot with HAR files and steps to generate a HAR file.

---

<div class="post-metadata">

**Author:** ![skot](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/skot/32/33281_2.png) [@skot](https://community.auth0.com/u/skot)\
**Post date:** [January 3, 2022, 3:26pm UTC](https://community.auth0.com/t/403-forbidden-returned-by-oauth-token/75568/4 "2022-01-03T15:26:38Z")

</div>

Yes,

I wound up using the plugin at [GitHub - sir-dunxalot/cypress-nextjs-auth0: Cypress commands to support Auth0 and Next.js](https://github.com/sir-dunxalot/cypress-nextjs-auth0)  
with this configuration:

```javascript
// cypress/plugins/index.js
import dotenv from 'dotenv';
dotenv.config({ path: '.env.local' });

const encrypt = require('cypress-nextjs-auth0/encrypt');

export default (on, config) => {
  // required for cypress-nextjs-auth0/encrypt
  // see https://github.com/sir-dunxalot/cypress-nextjs-auth0/issues/23#issuecomment-958144472
  on('task', { encrypt });
  config.env.auth0Audience = process.env.AUTH0_AUDIENCE;
  config.env.auth0Domain = process.env.AUTH0_ISSUER_BASE_URL;
  config.env.auth0ClientId = process.env.AUTH0_CLIENT_ID;
  config.env.auth0ClientSecret = process.env.AUTH0_CLIENT_SECRET;
  config.env.auth0CookieSecret = process.env.AUTH0_SECRET;
  config.env.auth0Scope = 'openid profile email';
  config.env.auth0SessionCookieName = 'appSession';
  config.env.auth0Username = process.env.AUTH0_TEST_USERNAME;
  config.env.auth0Password = process.env.AUTH0_TEST_PASSWORD;

  return config;
};

```

---

<div class="post-metadata">

**Author:** ![James.Morrison](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/james.morrison/32/13507_2.png) [@James.Morrison](https://community.auth0.com/u/James.Morrison)\
**Post date:** [January 17, 2022, 3:27pm UTC](https://community.auth0.com/t/403-forbidden-returned-by-oauth-token/75568/5 "2022-01-17T15:27:10Z")

</div>

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

---

<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:** [January 27, 2022, 12:11am UTC](https://community.auth0.com/t/403-forbidden-returned-by-oauth-token/75568/6 "2022-01-27T00:11:21Z")

</div>

Hi @skot,

Thank you for sending over the HAR file.

After inspecting your HAR file closely, I found that it did not capture the events leading up to the request to `/oauth/token` where you observed the _403 Forbidden_ error.

Generally, the _403 Forbidden_ error happens when the authorization code passed in the request is invalid, revoked, or expired. This is detailed in the [RFC 6749 - The OAuth 2.0 Authorization Framework](https://datatracker.ietf.org/doc/html/rfc6749#section-5.2) specification.

Looking further, I found that you also received an _“access\_denied”_ and _“unauthorized”_ error. This could happen when your request passed an incorrect _client\_id_ or _client\_secret_. You may also need to make sure that these values match the ones provided in your application settings in the Auth0 Dashboard.

Once that is complete, you can log in and obtain the access token.

If you have any further issues, please don’t hesitate to reach out.

Thank you.
