I have a web app that contains:
Now, I've got the (Identity) auth set up so that it has:
app.UseCookieAuthentication(...)
to setup the cookie auth for the web app; and
app.UseOAuthBearerTokens
and app.UseOAuthBearerAuthentication
to setup the token based side of things.
Is it possible to make sure that the MVC side of things doesn't support the tokens, and the web API side of things supports the tokens? Since some of the web API stuff is internal and some external, I think I'm happy if the API endpoints support either cookies or tokens.
Thanks.
The main difference between cookies and tokens is their nature: tokens are stateless while cookies are stateful. With this in mind, why is there a need to store authentication on the browser?
You obtain a bearer (access) token from the HttpContext with the GetTokenAsync method by passing the access_token argument. This is how you add the access token to the request header: Copy request. Headers.
Unless you have two different endpoints that can be differentiated at the Startup.cs
level, you would need to create a custom ActionFilter to handle this scenario.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With