-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add an example/tutorial for OAuth2 and Swagger #180
Comments
Great, it would be awesome to have a OAuth tutorial in the docs! For your problem, you can override the Swagger UI Twig template provided by API Platform (https://github.com/api-platform/core/blob/master/src/Bridge/Symfony/Bundle/Resources/views/SwaggerUi/index.html.twig) by creating a new one in Then, you can update the JS like in the Swagger UI: https://github.com/swagger-api/swagger-ui/blob/master/dist/index.html#L56-L66 What would be great, is to add new config options for OAuth credentials in the API Platform bundle and this snippet of JS directly in the JS file provided by the bundle. |
The correct path seems to be |
Do you know, where to store the I found something about |
Directly in the Swagger documentation: http://swagger.io/specification/#securityDefinitionsObject |
Do you have an example for decorating the existing Swagger normalizer? |
http://symfony.com/doc/current/service_container/service_decoration.html Basically something like: services:
app.swagger_normalizer:
class: AppBundle\Swagger\DocumentationNormalizer
decorates: api_platform.swagger.normalizer.documentation
arguments: ['@app.swagger_normalizer.inner']
public: false |
Now, I solved it temporarily by adding the following code to
$doc['securityDefinitions'] = [
'oauth' => [
'type' => 'oauth2',
'description' => 'OAuth2 client_credentials Grant',
'flow' => 'application',
'tokenUrl' => '/oauth/v2/token',
'scopes' => []
]
];
$doc['security'] = [
[
'oauth' => []
]
]; I will make it working via config.yml and add an pull request to the project. With the decorator I didn't got it working. |
Thank you very much for working on this. Can't wait for your PR. |
The implementation is ready and the documentation will follow next days. |
The |
Are we using the current swagger UI version? The password flow seems to be implemented in Dec 2016. |
Merge request for oauth core changes: api-platform/core#982 |
Thank you very much for all this work! I'm in vacation this week but I'll do a full review ASAP. |
Reopening this issue until the PR is merged. |
The PR with the code changes seem to have been merged, but there are still some comments left on the documentation PR. @iCodr8, would you be able to pick those up please? |
This is my config for the OAuth support in swagger:
|
Currently I've added FOSOAuthServerBundle to my application to get OAuth2 support. This is working, but now I can not use the "Try out!"-Button in SwaggerUI, because I am not authenticated.
It would be nice to have an example for OAuth2 with Swagger Login support.
If someone tells me the solution, I am willing to write the tutorial.
The text was updated successfully, but these errors were encountered: