Forum Discussion

wesleytang's avatar
wesleytang
New Contributor
2 years ago

Pass Credentials to Embedded Swagger UI's Try it Out

I have a web application that has a Swagger UI 4 embedded in one of the pages (using the swagger-ui-dist dependency free version). When I use Try it Out, I am contacting a server that exists at the s...
  • ponelat's avatar
    2 years ago

    Hi wesleytang ,

     

    Sounds like it could either be a bug, or it could be something unusual in how it's embedded.

    When you say the user is already logged in, are you referring to a Cookie session? That should work just fine if SwaggerUI is part of the same domain (as you said, embedded). 

    Setting credentials = include, might help (not sure how the interceptor would be set up for that, but I know it's in  there somewhere)... but it should also only apply to different domains, not the same domain you're already on.

     

    Take a look at the Network tab in your browser and see what headers are (not) being sent.

     

    Also note that "Authenticating" inside SwaggerUI doesn't create a cookie session for your underlying app, that doesn't set up a cookie only updates internal state.