Closed
Description
I am using Swagger UI 3.0 which comes with SwaggerUIBundle
. My code is the same as example one in dist
folder.
window.onload = function() {
// Build a system
const ui = SwaggerUIBundle({
url: "my_spec_address",
dom_id: '#swagger-ui',
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
})
window.ui = ui
}
I searched all day to find solution to put an auth-token header when clicking try it out
. But there is NONE.
There are no full documents for this project. I don't know how I can solve this problem.
Can someone help me please?
Activity
webron commentedon May 16, 2017
Depending on the type of auth-token you want to add, the recommended approach would be to use the
security
property in your spec.We are working on a way to customize the requests, which I hope to be released this upcoming weekend (but available in master before then).
mccool commentedon May 16, 2017
I've also been searching for a way to dynamically add the header
Authorization: Basic xxxxx=
. I'm giving the user a dropdown of keys to use to authenticate, so it would be nice to add the header for them on change. I tried.authActions.authorizePassword({passwordType:'basic', username:'user',password:'password'})
, but got an error onauth.scopes.join
sincescopes
isn't defined.Nothing else stuck out to me in the object returned from calling SwaggerUIBundle. @webron are you thinking this functionality will be added in 3.0.11?
webron commentedon May 16, 2017
@mccool that's our goal, no guarantees ;)
mccool commentedon May 16, 2017
@webron Sure, I understand. The goal is to add the header

Authorization: Basic base64 string here
to the request sent out using the Try it out button without using the Authorization modal and without using the default menu that opens in chrome. I'm guessing this may already be there I just can't find it.
In v2.x I was using
where
basic
was the value I used for the Authorization header. It's the usualBasic user:pass
encoded with
btoa
.webron commentedon May 16, 2017
I manage to typo,
that's
towhat's
(fixed now). Yes, I'm gifted. Sorry about for the confusion :)mccool commentedon May 16, 2017
I just noticed the edit! No worries!
shockey commentedon Jun 30, 2017
Closing due to inactivity - feel free to comment if there are any further thoughts or concerns, and we'll be happy to reopen this issue.
deepa456 commentedon Jul 1, 2017
I am using Swagger UI 3.0 which comes with SwaggerUIBundle. My code is the same as example one in dist folder.
window.onload = function() {
// Build a system
const ui = SwaggerUIBundle({
url: "my_spec_address",
dom_id: '#swagger-ui',
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
})
window.ui = ui
}
I want to pass some custom request headers . Tried adding an XMLHttpInterceptor Interceptor. Even that did not help. what is the easy way to pass custom headers as part of every request ?
marcgibbons commentedon Jul 12, 2017
@shockey To tack onto this issue, I think it would be useful to expose configurable options for
fetch
calls for both downloading the OpenAPI spec and by the Try It / Execution package.Use cases would be:
credentials
option (somewhat related to: Allow */* mime type response, send cookies when downloading spec #2822)This is a somewhat of a blocker to upgrade to v3:
marcgibbons/django-rest-swagger#637
shockey commentedon Jul 12, 2017
@marcgibbons, see below:
swaggerProxy
option for request interception here: Add possibility to loading a Swagger spec (.json/.yaml) that is protected by Basic auth. UI version 3.0 #2793 (comment)credentials: same-origin
when fetching specs a little while ago: Add same-origin credentials policy to makeFetchJSON swagger-js#1083shockey commentedon Jul 12, 2017
Locking this closed support ticket! Please direct your comments to a new support ticket, or feel free weigh in on #2793.
1 remaining item