The current version of swagger-ui will just read the security definitions from 
your spec (including basic auth) and allow you to set it using the `Authorize` 
button. No extra wiring is needed.

 

 

 

From: <[email protected]> on behalf of amit dwivedi 
<[email protected]>
Reply-To: "[email protected]" 
<[email protected]>
Date: Sunday, 1 January 2017 at 4:46
To: Swagger <[email protected]>
Subject: Basic authentication in swagger docs

 

hi  

i want to implement swagger docs with Basic authentication but problem is 
unable to add Basic authentication

i used all Technic what suggested like 

 
Header Parameters
Header params are supported through a pluggable mechanism in swagger-js. You 
can see the index.html for a sample of how to dynamically set headers:

// add a new SwaggerClient.ApiKeyAuthorization when the api-key changes in the 
ui.
$('#input_apiKey').change(function() {
  var key = $('#input_apiKey')[0].value;
  if(key && key.trim() != "") {
    swaggerUi.api.clientAuthorizations.add("auth_name", new 
SwaggerClient.ApiKeyAuthorization("api_key", key, "header"));
  }
})
This will add the header api_key with value key on calls that have the 
auth_name security scheme as part of their swaggerDefinitions. You can 
substitute query to send the values as a query param.
Custom Header Parameters - (For Basic auth etc)
If you have some header parameters which you need to send with every request, 
use the headers as below:

swaggerUi.api.clientAuthorizations.add("key", new 
SwaggerClient.ApiKeyAuthorization("Authorization", "XXXX", "header"));
Note! You can pass multiple header params on a single request, just use unique 
names for them (key is used in the above example).

 

 

 

but this is also not working 

so if any full example for basic authentication. please help me  

-- 
You received this message because you are subscribed to the Google Groups 
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google Groups 
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to