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

Allow Swagger UI pre-authorization #278

Closed
nlarusstone opened this issue Jan 29, 2021 · 4 comments
Closed

Allow Swagger UI pre-authorization #278

nlarusstone opened this issue Jan 29, 2021 · 4 comments

Comments

@nlarusstone
Copy link

When developing locally on an API that has token or API key based authentication, I would like to not have to fill in my API Key every time I use Swagger UI.

Swagger provides this using the preauthorizeApiKey (I believe), but it doesn't seem possible to do locally:
https://stackoverflow.com/questions/45199989/how-do-i-automatically-authorize-all-endpoints-with-swagger-ui/50181701#50181701

@tfranzel
Copy link
Owner

i was not aware of this feature. we currently do not support call-back setttings for swagger ui, just simple settings.

https://drf-spectacular.readthedocs.io/en/latest/settings.html#example-swaggerui-settings

however, there is the SwaggerUI setting persistAuthorization: true which will remember the auth on reload. so you only need to do it once, which is probably close enough for you.

@tfranzel
Copy link
Owner

sry... i mistyped the issue number. this is unrelated

@nlarusstone
Copy link
Author

Yup, persistAuthorization works for my usecase, thanks!

@callumgare
Copy link
Contributor

Another option for anyone who comes across this issue is automatically configuring the session cookie authentication if a user has logged in: #1099 (comment)

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

3 participants