# Configure ASP .NET Web API middleware to accept HS256 and RS256

**URL:** <https://community.auth0.com/t/configure-asp-net-web-api-middleware-to-accept-hs256-and-rs256/8678>\
**Category:** Get Help\
**Tags:** aspnet-core, middleware, aspnet\
**Created:** [November 6, 2017, 9:47pm UTC](https://community.auth0.com/t/configure-asp-net-web-api-middleware-to-accept-hs256-and-rs256/8678 "2017-11-06T21:47:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sarala.muralikrishna](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@sarala.muralikrishna](https://community.auth0.com/u/sarala.muralikrishna)\
**Post date:** [November 6, 2017, 9:47pm UTC](https://community.auth0.com/t/configure-asp-net-web-api-middleware-to-accept-hs256-and-rs256/8678/1 "2017-11-06T21:47:32Z")

</div>

I am developing an restful API using ASP .NET Web API, as you can imaging there will be many clients using it developed in many different languages. I see that in Auth0 samples for .NET core example they setup to use HS256. So my question is can I setup my ASP .NET Web API middleware to accept both algorithms?

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [November 6, 2017, 11:00pm UTC](https://community.auth0.com/t/configure-asp-net-web-api-middleware-to-accept-hs256-and-rs256/8678/2 "2017-11-06T23:00:23Z")

</div>

In general there is no point in doing what you describe because assuming the client application will obtain the access token to call your API through an OAuth2 flow then the access token being issued is meant to be treated as an opaque value by the client application. The application only has to obtain and send the token in the requests to the API.

With the above in mind the only parties that care about the access token format/signing approach are the authorization server (who has to issue it) and possibly the API (who has to validate it assuming the token is a self-contained one).

In conclusion, you can have/develop as many client application that you want and implemented with as many different languages as you desire because the only thing they will have to is talk OAuth2 (HTTP) to get the token and then call the API.

---

<div class="post-metadata">

**Author:** ![sarala.muralikrishna](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@sarala.muralikrishna](https://community.auth0.com/u/sarala.muralikrishna)\
**Post date:** [November 6, 2017, 11:56pm UTC](https://community.auth0.com/t/configure-asp-net-web-api-middleware-to-accept-hs256-and-rs256/8678/3 "2017-11-06T23:56:33Z")

</div>

Hi,  
Thanks for your reply, my api application is using ID Token so that I can get all the required information (client is passing me ID Token not access token). The client which is connecting to auth0 and getting the token can be anything as described in my original question. So how do you deal with this?

Thanks and Regards  
Murali

---

<div class="post-metadata">

**Author:** ![sarala.muralikrishna](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@sarala.muralikrishna](https://community.auth0.com/u/sarala.muralikrishna)\
**Post date:** [November 6, 2017, 11:56pm UTC](https://community.auth0.com/t/configure-asp-net-web-api-middleware-to-accept-hs256-and-rs256/8678/4 "2017-11-06T23:56:33Z")

</div>

Hi,  
Thanks for your reply, my api application is using ID Token so that I can get all the required information (client is passing me ID Token not access token). The client which is connecting to auth0 and getting the token can be anything as described in my original question. So how do you deal with this?

Thanks and Regards  
Murali

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [November 10, 2017, 10:21pm UTC](https://community.auth0.com/t/configure-asp-net-web-api-middleware-to-accept-hs256-and-rs256/8678/5 "2017-11-10T22:21:12Z")

</div>

The issue is that you’re sending an ID token to an API as a method of authorization and that is incorrect; as mentioned in the answer you should be sending an access token. See the following for more info on this topic: [Access Tokens](https://auth0.com/docs/api-auth/why-use-access-tokens-to-secure-apis)

---

<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 2, 2018, 5:57am UTC](https://community.auth0.com/t/configure-asp-net-web-api-middleware-to-accept-hs256-and-rs256/8678/6 "2018-03-02T05:57:18Z")

</div>


