question

SrinuNani avatar image
0 Votes"
SrinuNani asked RakeshJagatap-4451 commented

How to Integrate Microsoft Identity MSAL authentication with Swagger?

Hi Team,

I am Integrating Microsoft Identity MSAL authentication with Swagger, unable to fix this issue, please suggest your references.

 services.AddMicrosoftWebAppAuthentication(Configuration, "AzureAd")                
   .AddMicrosoftWebAppCallsWebApi(Configuration, "AzureAd")
   .AddInMemoryTokenCaches();


This code works for my Web APi Authentication, but I want to test this authentication with swagger.

dotnet-aspnet-core-webapiazure-ad-msal
· 1
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.

Hi, if the posted answer resolves your question, please mark it as the answer by clicking the check mark. Doing so helps others find answers to their questions.

0 Votes 0 ·

1 Answer

kaml avatar image
0 Votes"
kaml answered kaml edited

If I understand correctly, your web API works fine with MSAL but you want to protect swagger with authn?

Swagger uses its own protocol for authn and authz.

Take a look at this sample project. It may help you: https://github.com/klagan/sample-dotnet/tree/master/src/OpenAPI/MyWebAPI

Line 138 of startup.cs is where the swagger authn initialisation begins

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.