Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Add Authentication to Swagger #2425


User avatar
0
paymanrowhani created

Hi,

How can I add authentication to swagger for dotnet core application (the version that comes with angular2)? I need to test the api, but the requests are not authorized...

Thanks, Payman


4 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Please see this document <a class="postlink" href="http://aspnetboilerplate.com/Pages/Documents/Swagger-UI-Integration#aspnet-core">http://aspnetboilerplate.com/Pages/Docu ... spnet-core</a>. It explanins how to add csrfToken to swagger requests. You need to add auth token just like the csrfToken explained in the document.

  • User Avatar
    0
    paymanrowhani created

    Hi,

    Angular2 Web.Host project has no wwwroot\swagger\ui\index.html. What can I do?

    Thanks, Payman

  • User Avatar
    0
    paymanrowhani created

    I added the index file, but still I'm now clear how to do it.... Suppose I have a username and password, how can I get token from it? How can I enable authorization for swagger then? Do I need to add any security definition to AddSwaggerGen?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Sorry, I think I missunderstand you. Can you check this answer and see if it fits your case ? #2258@f0545ef1-23f7-4fb2-bafe-3afc7899b995