-
-
Notifications
You must be signed in to change notification settings - Fork 839
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
Swagger UI OAuth2 not working due to missing oauth2-redirect.html #1097
Comments
how to fix that? |
I'm having this same problem and am not sure what to do, or why "oauth2-redirect.html" is hardcoded to localhost.... |
I finally figured out the solution to this for me: https://stackoverflow.com/questions/49518868/oauth2-authorization-in-nelmioapidocbundle/49519134#49519134 |
could we make this configurable? that would mean that we need to make this js file a twig template and render it through a controller... meanwhile, could you create a PR faq page @Lopton to explain how to configure swagger-ui, with the example of configuring oauth? to make it a complete documentation, it should mention that the js file path is likely a symlink or a copy, and will be overwritten each time assets:install is run. (i think we can't overwrite the file in app/Resources/... - that only works for twig templates, right?) |
For context, the linked stackoverflow solution is to change the options passed to const ui = SwaggerUIBundle({
oauth2RedirectUrl: 'URLhere',
// ...
}); There's already some configurabily in place now vis
Which are passed in via the twig template: NelmioApiDocBundle/Resources/views/SwaggerUi/index.html.twig Lines 79 to 80 in 9cd417e
NelmioApiDocBundle/Render/Html/HtmlOpenApiRenderer.php Lines 44 to 58 in 9cd417e
I'm 50/50 here, this is probably a good idea to make configurable, but it's also pretty easy to do in twig by overriding the template now:
Open to feedback. I honeslty do not use the auth bits of swagger UI. |
Going to close this one in favor of #1330 |
In the Swagger UI its possible to authorize the client using OAuth2. Currently in the NelmioApiDocBundle this is not working due to two issues:
oauth2RedirectUrl
can not be configured (this defaults tohttp://localhost:3000/oauth2-redirect.html
).oauth2-redirect.html
itself is missing. This file is responsible for retrieving the OAuth token and setting the Bearer token in subsequent requests from the Swagger UI.As a simple test I copied the
https://github.com/swagger-api/swagger-ui/blob/master/dist/oauth2-redirect.html
in my web root and exposed it onhttp://localhost:3000/oauth2-redirect.html
and then it seems to be working.However it would be much easier if NelmioApiDocBundle included this file and set the
oauth2RedirectUrl
to a absolute URL generated by for example a route to this view.The text was updated successfully, but these errors were encountered: