Sorry to reply to an older post, but I wanted to make sure I searched to 
see if there was an answer to this question before posting.

I'm also working on an API that currently has only Digest Authentication. 
 I'm aware of the security risks with this, and we will probably switch to 
OAuth in the future, but for now, we're building up the service using 
Digest Auth.  I guess I just expected this to be an option, and I was 
disappointed to see that the "Try It" feature in the Swagger UI would not 
work with Digest Auth, since that would be very useful as we build and 
troubleshoot clients.  Is there a workaround for this?


On Tuesday, September 27, 2016 at 5:58:05 AM UTC-5, Emanuele Bastianelli 
wrote:
>
> I'm using Swagger to produce the documentation of my REST API. According 
> to what is written around, the Swagger UI does not offer support for basic 
> authentication (differently from the online editor 
> <http://editor.swagger.io/>). My problem is that one of my APIs is a POST 
> that require digest (not even basic) authentication.
>
>
> A possible solution I found around is to add a fixed user:pass 
> authentication header in the request via javascript code. This should be 
> easily done according to the Swagger UI documentation 
> <https://github.com/swagger-api/swagger-ui> (see Custom Header Parameters 
> <https://github.com/swagger-api/swagger-ui#custom-header-parameters---for-basic-auth-etc>).
>  
> I report the incriminated code line:
>
>
> swaggerUi.api.clientAuthorizations.add("key", new 
> SwaggerClient.ApiKeyAuthorization("Authorization", "XXXX", "header"));
>
>
> Unfortunately it doesn't work. The swaggerUi.api field results 
> uninitialised (null) after I initialise the SwaggerUi object, and as a 
> consequence swaggerUi.api.clientAuthorizationsis undefined. I tried 
> initialising such fields in different way, failing every time. I tried also 
> similar calls to the API I found in threads discussing this topic, but none 
> of them has worked. Does anyone have an idea about that? The documentation 
> is not particularly clear about that.
>
> For completeness, I report the js snippet where I initialise the SwaggerUI 
> object
>
>
>   var urlPush = "./doc_push.yaml";
>   window.swaggerUiPush = new SwaggerUi({
>         url: urlPush,
>         dom_id: "swagger-ui-container-push",
>         supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
>         onFailure: function(data) {
>           log("Unable to Load SwaggerUI");
>         },
>         docExpansion: "list",
>         jsonEditor: false,
>         defaultModelRendering: 'model',
>         showRequestHeaders: false,
>    });
>
>

-- 
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