How to specify the authorization token header in Swagger-UI

16,115 views
Skip to first unread message

j3d

unread,
Apr 17, 2014, 3:58:24 PM4/17/14
to swagger-sw...@googlegroups.com
I'm documenting my REST API with Swagger... and it works fine. Now I've also added functionality for dealing with authorization. When an user logs in, he gets back a token that must be used in each subsequent request (i.e. each request must contain a header like "Authorization: Token af538baa9045a84c0e889f672baf83ff24"). How do I make swagger add this header? Since my API generates a different token for each log in, is there a way to specify the token in Swagger-UI?

Thanks.

tony tam

unread,
Apr 17, 2014, 4:14:14 PM4/17/14
to swagger-sw...@googlegroups.com
if you're using oauth2, you can follow this guideline:


Otherwise, it's easy to programmatically add a header.  See here:


window.authorizations.add("key", new ApiKeyAuthorization("Authorization", "XXXX", "header"));

Reply all
Reply to author
Forward
0 new messages