# How to validate web app Access Token from External API

**URL:** <https://community.auth0.com/t/how-to-validate-web-app-access-token-from-external-api/59015>\
**Category:** Get Help\
**Tags:** api\
**Created:** [March 6, 2021, 8:20pm UTC](https://community.auth0.com/t/how-to-validate-web-app-access-token-from-external-api/59015 "2021-03-06T20:20:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gabbourget](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/gabbourget/32/25661_2.png) [@gabbourget](https://community.auth0.com/u/gabbourget)\
**Post date:** [March 6, 2021, 8:20pm UTC](https://community.auth0.com/t/how-to-validate-web-app-access-token-from-external-api/59015/1 "2021-03-06T20:20:59Z")

</div>

I did the base setup for a Nextjs app using Auth0. In the example, you get this

```
import { getAccessToken, getSession } from "@auth0/nextjs-auth0";

export default async (req, res) => {
const { accessToken } = await getAccessToken(req, res);

    const result = await fetch("https://localhost:44336/weatherforecast", {
      headers: {
        Authorization: `Bearer ${accessToken}`,
      },
    });

```

This external API is something I just created in c#. I created a Machine to Machine Api in Auth0 dashboard and authorized my webApp. It just won’t work. User isn’t set and Authorization attribute isn’T working.

I wonder how it can works actually. The Api setup tells me to add JwtBearer Auth, however, AccessToken from Webapp isn’t a Jwt…

What am I missing?  
Here my c# setup:

```
services.AddAuthentication(options =>
      {
        options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
        options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
      }).AddJwtBearer(options =>
      {
        options.Authority = "https://myorg.auth0.com/";
        options.Audience = "MyAPIAudience";
      });

```

---

<div class="post-metadata">

**Author:** ![supun](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/supun/32/17069_2.png) [@supun](https://community.auth0.com/u/supun)\
**Post date:** [March 7, 2021, 3:28am UTC](https://community.auth0.com/t/how-to-validate-web-app-access-token-from-external-api/59015/2 "2021-03-07T03:28:02Z")

</div>

Hi @gabbourget ,

Welcome to the Auth0 community!

When you are authenticating the user in the NextJs application, have you set an audience value in the authentication request, and does it match with API Identifier?

---

<div class="post-metadata">

**Author:** ![gabbourget](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/gabbourget/32/25661_2.png) [@gabbourget](https://community.auth0.com/u/gabbourget)\
**Post date:** [March 7, 2021, 5:48pm UTC](https://community.auth0.com/t/how-to-validate-web-app-access-token-from-external-api/59015/3 "2021-03-07T17:48:17Z")

</div>

Nop didn’t understand that. I got it working now with audience AND setting scope.

Thx

---

<div class="post-metadata">

**Author:** ![supun](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/supun/32/17069_2.png) [@supun](https://community.auth0.com/u/supun)\
**Post date:** [March 8, 2021, 3:03am UTC](https://community.auth0.com/t/how-to-validate-web-app-access-token-from-external-api/59015/4 "2021-03-08T03:03:27Z")

</div>

Great! thank you for sharing the solution with us.

---

<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:** [March 23, 2021, 3:03am UTC](https://community.auth0.com/t/how-to-validate-web-app-access-token-from-external-api/59015/5 "2021-03-23T03:03:49Z")

</div>

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