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

#592 Ported automatic access token retrieval from openapi-generator #593

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

trohrberg
Copy link

Fix issue #592

The OpenAPITools/openapi-generator generates Java client SDK with okHttp which provides an automatic retrieval of an OAuth2 access token. This is done by registering an interceptor (RetryingOAuth class) extending the OAuth class to the okHTTP client instantiated in the ApiClient class. With that any outgoing HTTP call from the client SDK is intercepted and preceeding call to the Auth-Server is done first to retrieve an access token. That access token is then added to the original outgoing HTTP call providing an authorized access to the actual API.

…generator

The OpenAPITools/openapi-generator generates Java client SDK with okHttp which provides an automatic retrieval of an OAuth2 access token. This is done by registering an interceptor (RetryingOAuth class) extending the OAuth class to the okHTTP client instantiated in the ApiClient class. With that any outgoing HTTP call from the client SDK is intercepted and preceeding call to the Auth-Server is done first to retrieve an access token. That access token is then added to the original outgoing HTTP call providing an authorized access to the actual API.
@trohrberg trohrberg requested a review from HugoMario February 4, 2020 13:32
@trohrberg
Copy link
Author

@HugoMario - Hints for code review:

I'm not sure if the OAuthOkHttpClient.mustache and RetryingOAuth.mustache should only be included in the generating process within JavaClientCodegen.java if OAuth is specified in the corresponding YAML. In OpenAPITools/openapi-generator, from which I ported the corresponding code, it is done that way. However, the OAuth.mustache template is also always included. For that I followed the same approach for the new templates.

trohrberg pushed a commit to trohrberg/swagger-codegen-generators that referenced this pull request Feb 15, 2020
…generator

The OpenAPITools/openapi-generator generates Java client SDK with okHttp which provides an automatic retrieval of an OAuth2 access token. This is done by registering an interceptor (RetryingOAuth class) extending the OAuth class to the okHTTP client instantiated in the ApiClient class. With that any outgoing HTTP call from the client SDK is intercepted and preceeding call to the Auth-Server is done first to retrieve an access token. That access token is then added to the original outgoing HTTP call providing an authorized access to the actual API.

Changes for pull request swagger-api#592:
(swagger-api#593)
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

Successfully merging this pull request may close these issues.

1 participant