Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for conflicting headers? #1261

Closed
rustybailey opened this issue May 11, 2015 · 2 comments
Closed

Workaround for conflicting headers? #1261

rustybailey opened this issue May 11, 2015 · 2 comments

Comments

@rustybailey
Copy link

Is there any way to get around conflicting header names? I am using 2-legged OAuth2 in my API, so I have documented the token route which uses an "Authorization" header with "Basic [key]" and the route returns a token. However every other route uses a header that is "Authorization: Bearer [token]" which is implemented using the method below:

        var accessToken = new SwaggerClient.ApiKeyAuthorization("Authorization", authHeader, "header");
        window.swaggerUi.api.clientAuthorizations.add("key", accessToken);

It seems that when that Authorization header is set globally, there is no way for a header with the same name to be overwritten on a route-by-route basis. My only solution right now is disabling the "Try It Now" button for the token route. Is there a way for both of them to exist together while still be able to prepopulate a token?

@rustybailey
Copy link
Author

After consulting with some members on the #swagger irc, the solution was to set up securityDefinitions in my swagger.json, set "oauth2" as the global security and set "basic" as the security for the token route. Everything works as expected now.

@webron
Copy link
Contributor

webron commented May 11, 2015

Thanks for providing the information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants