question

AshvinRavishankar-3518 avatar image
0 Votes"
AshvinRavishankar-3518 asked DanielZhang-MSFT edited

ASP.Net Core 3.1 Authentication Web API

Hi All,

I am trying to implement a project for my self learning.

I am trying to create a project with both basic and token based authentication using web api / .net core. I would like to have the project wherein a user can call swagger and opt for Basic authentication or token based authentication (using parameters to api call).

Eg. The user would pass 1 for basic authentication with username/password or 2 for token based authentication. The project would call the required controller to authenticate the user with the user desired authentication.

Is there a sample code available.

Thanks,
Ashvin

dotnet-aspnet-core-general
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

There are ASP.NET tags you can post to for help, the Core WebAPI tag.

0 Votes 0 ·

It's possible to configure two different authentication provides. Make sure one of the providers is the default and you must explicitly define the authentication type(s) a controller or action uses.

https://jasonwatmore.com/post/2019/10/21/aspnet-core-3-basic-authentication-tutorial-with-example-api
https://jasonwatmore.com/post/2019/10/11/aspnet-core-3-jwt-authentication-tutorial-with-example-api

I recommend building separate projects to get the authentication working then create a third project to combine the two authentication providers. I'm not sure what opt for Basic or token means.


0 Votes 0 ·

0 Answers