# Failed to load resource: the server responded with a status of 401 () in React.js/Nest.js

**URL:** <https://community.auth0.com/t/failed-to-load-resource-the-server-responded-with-a-status-of-401-in-react-js-nest-js/121743>\
**Category:** Get Help\
**Tags:** connections-management-api, management-api\
**Created:** [November 27, 2023, 9:22pm UTC](https://community.auth0.com/t/failed-to-load-resource-the-server-responded-with-a-status-of-401-in-react-js-nest-js/121743 "2023-11-27T21:22:25Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![ludovicoc](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ludovicoc/32/52764_2.png) [@ludovicoc](https://community.auth0.com/u/ludovicoc)\
**Post date:** [November 27, 2023, 9:22pm UTC](https://community.auth0.com/t/failed-to-load-resource-the-server-responded-with-a-status-of-401-in-react-js-nest-js/121743/1 "2023-11-27T21:22:25Z")

</div>

Hello webdev newbie here, i have seen this issue before in getting Failed to load resource: the server responded with a status of 401 () in /oauth/token.

My frontend is in React.js and backend is with Nest.js, it does work without issue if i set up the auth method ‘none’ but i’d like to my set up on Clinet Secret (Basic), any help would be appreciated!

```auto
// auth.strategy.ts
@Injectable()
export class Auth0Strategy extends PassportStrategy(Strategy, 'auth0') {
  constructor() {
    super({
      clientID: process.env.AUTH0_CLIENT_ID,
      clientSecret: process.env.AUTH0_CLIENT_SECRET,
      domain: process.env.AUTH0_DOMAIN,
      callbackURL: process.env.AUTH0_CALLBACK_URL,
      scope: 'openid profile email',
      state: false
    });
  }
  async validate(accessToken, refreshToken, extraParams, profile, done): Promise<any> {
    return done(null, profile);
  }
}

```

```auto
// auth.guard.ts
@Injectable()
export class Auth0Guard extends AuthGuard('auth0') {}
async validate(accessToken, refreshToken, extraParams, profile, done): Promise<any> {
    return done(null, profile);
  }
}

```

```auto
import React, { useEffect } from 'react';
import { useAuth0 } from '@auth0/auth0-react';
import { getAllFeed } from '../api/asset';

const Feed = () => {
  const { user, isAuthenticated, getAccessTokenSilently } = useAuth0();

  if (!isAuthenticated) {
    return <div>Loading or not authenticated...</div>;
  }

  return (
    <div>
      <h2>User Profile</h2>
      {/* Display user's info */}
      <p>Name: {user.name}</p>
      <p>Email: {user.email}</p>
      {/* ... other user information */}
    </div>
  );
};

export default Feed;

```

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [November 28, 2023, 1:43am UTC](https://community.auth0.com/t/failed-to-load-resource-the-server-responded-with-a-status-of-401-in-react-js-nest-js/121743/3 "2023-11-28T01:43:02Z")

</div>

Hey there @ludovicoc welcome to the community!

I am guessing the `clientID` in question has the `token_endpoint_auth_method` set to `none` which won’t allow you to perform a client credentials exchange. You’ll need to update the `token_endpoint_auth_method` to `client_secret_basic` using the [Management API](https://auth0.com/docs/api/management/v2/clients/patch-clients-by-id).

---

<div class="post-metadata">

**Author:** ![ludovicoc](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ludovicoc/32/52764_2.png) [@ludovicoc](https://community.auth0.com/u/ludovicoc)\
**Post date:** [November 28, 2023, 6:21pm UTC](https://community.auth0.com/t/failed-to-load-resource-the-server-responded-with-a-status-of-401-in-react-js-nest-js/121743/4 "2023-11-28T18:21:00Z")

</div>

hey @ty.frith thanks for the quick reply, i did exactly that and I’m getting the error I mentioned above, when it’s set ‘none’ everything works smoothly. Am I missing something in order to make it work with client secret (basic) ?

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [November 29, 2023, 1:40am UTC](https://community.auth0.com/t/failed-to-load-resource-the-server-responded-with-a-status-of-401-in-react-js-nest-js/121743/5 "2023-11-29T01:40:35Z")

</div>

Hey @ludovicoc no problem, happy to help!

Do you mind DMing me the tenant and specific `client_id` you are working with so I can take a closer look at your settings?

---

<div class="post-metadata">

**Author:** ![ludovicoc](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ludovicoc/32/52764_2.png) [@ludovicoc](https://community.auth0.com/u/ludovicoc)\
**Post date:** [November 29, 2023, 11:51am UTC](https://community.auth0.com/t/failed-to-load-resource-the-server-responded-with-a-status-of-401-in-react-js-nest-js/121743/6 "2023-11-29T11:51:57Z")

</div>

> [@ty.frith](#):
>
> Do you mind DMing me the tenant and specific `client_id` you are working with so I can take a closer look at your settings?

Sure, just sent it over 🙂

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [November 30, 2023, 1:25am UTC](https://community.auth0.com/t/failed-to-load-resource-the-server-responded-with-a-status-of-401-in-react-js-nest-js/121743/7 "2023-11-30T01:25:09Z")

</div>

Awesome, thanks!

Can you share a bit more detail regarding where/how specifically you are running into this error? I guess I’d also like to learn why the need to use client secret (basic) in the context of your application. Typically, there is no need for a client credentials exchange in a user authentication/authorization flow but rather when authenticating the client itself against a resource (think [machine to machine](https://auth0.com/blog/using-m2m-authorization/)).

The more information you can provide about your specific use case the better!

---

<div class="post-metadata">

**Author:** ![ludovicoc](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ludovicoc/32/52764_2.png) [@ludovicoc](https://community.auth0.com/u/ludovicoc)\
**Post date:** [November 30, 2023, 2:06pm UTC](https://community.auth0.com/t/failed-to-load-resource-the-server-responded-with-a-status-of-401-in-react-js-nest-js/121743/8 "2023-11-30T14:06:25Z")

</div>

yes of course I DM’you with more details, thanks again

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [December 1, 2023, 12:16am UTC](https://community.auth0.com/t/failed-to-load-resource-the-server-responded-with-a-status-of-401-in-react-js-nest-js/121743/9 "2023-12-01T00:16:17Z")

</div>

Resolved in a DM as additional context was needed 😄

---

<div class="post-metadata">

**Author:** ![ludovicoc](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ludovicoc/32/52764_2.png) [@ludovicoc](https://community.auth0.com/u/ludovicoc)\
**Post date:** [December 1, 2023, 4:30pm UTC](https://community.auth0.com/t/failed-to-load-resource-the-server-responded-with-a-status-of-401-in-react-js-nest-js/121743/10 "2023-12-01T16:30:30Z")

</div>

Thanks again @tyf this was great and super helpful!

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [December 4, 2023, 10:22pm UTC](https://community.auth0.com/t/failed-to-load-resource-the-server-responded-with-a-status-of-401-in-react-js-nest-js/121743/11 "2023-12-04T22:22:26Z")

</div>

No problem @ludovicoc I’m happy I was able to help!

---

<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:** [December 18, 2023, 10:22pm UTC](https://community.auth0.com/t/failed-to-load-resource-the-server-responded-with-a-status-of-401-in-react-js-nest-js/121743/12 "2023-12-18T22:22:32Z")

</div>

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