# 401/Unauthorized calling from SPA to custom API

**URL:** <https://community.auth0.com/t/401-unauthorized-calling-from-spa-to-custom-api/83867>\
**Category:** Get Help\
**Created:** [May 21, 2022, 4:40pm UTC](https://community.auth0.com/t/401-unauthorized-calling-from-spa-to-custom-api/83867 "2022-05-21T16:40:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlwaysBuyCheap](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/alwaysbuycheap/32/37506_2.png) [@AlwaysBuyCheap](https://community.auth0.com/u/AlwaysBuyCheap)\
**Post date:** [May 21, 2022, 4:40pm UTC](https://community.auth0.com/t/401-unauthorized-calling-from-spa-to-custom-api/83867/1 "2022-05-21T16:40:32Z")

</div>

I’m trying to call a custom API on .net core from a js SPA, the authentification works fine but when I call the api it returns 401, using the access token. I don’t have any scopes or permissions set.  
Does anyone know why this happens?

Edit: I’ve checked the bearer token that I received and it doesn’t seem valid, at least in the RS256 format.

---

<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:** [May 23, 2022, 10:00pm UTC](https://community.auth0.com/t/401-unauthorized-calling-from-spa-to-custom-api/83867/3 "2022-05-23T22:00:17Z")

</div>

Hi there @AlwaysBuyCheap welcome to the community!

> [@AlwaysBuyCheap](#):
>
> I’ve checked the bearer token that I received and it doesn’t seem valid, at least in the RS256 format

I’m assuming this is due to the Access Token missing an audience (aud) claim - This is specified as a param in the `/authorize` request and might be a good place to start.  
[https://community.auth0.com/t/what-is-the-audience/71414](https://community.auth0.com/t/what-is-the-audience/71414)

I also came across the following topic which may be of use:

> [@.NET Core Angular 401 when calling API](https://community.auth0.com/t/net-core-angular-401-when-calling-api/71413):
>
> Hi, I have a .NET Core Angular app that has been setup to make secure calls to an API using but I’m getting a 401error when the client application makes the call to the API. This issue has been reported several times, but none of the previous posts provide a solution. I used the auth0-angular SDK as per the guidance in the [Complete Guide to Angular User Authentication](https://auth0.com/blog/complete-guide-to-angular-user-authentication/#Calling-an-API) and the instructions the from the [Authorization for ASP.NET Web APIs](https://auth0.com/blog/aspnet-web-api-authorization/) blog post to setup authorization for the API. I can secur…

Let us know!

---

<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:** [June 7, 2022, 10:00pm UTC](https://community.auth0.com/t/401-unauthorized-calling-from-spa-to-custom-api/83867/4 "2022-06-07T22:00:28Z")

</div>

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