swagger-api / swagger-api/swagger-codegen-generators
Automatically request OAuth2 access token for outgoing HTTP call from client
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 299
- Forks
- 439
- PR merge metrics
- No merged PRs in 30d
Description
Recently, I was using OpenAPITools/openapi-generator for generating a Java/okHTTP based client SDK for my REST interface specified in OpenAPI version 3.0.2. Unfortunately, that generator had problems with inheritance defined in my models. For that - and other - reasons, I would like to us the swagger-codegen generator instead. However, that seems to miss the very handy feature of automatically requesting an access token for outgoing HTTP calls from the client SDK.
In the OpenAPITools/openapi-generator that feature is done by registering an interceptor 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.
Since I already figured how it works in the OpenAPITools/openapi-generator, I am going to try to provide a pull request with that feature shortly.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Compare the OpenAPITools/openapi-generator OAuth interceptor approach with the Java/okHTTP client generated through swagger-codegen, focusing on the ApiClient class and its okHTTP client. The work is done when outgoing calls request an access token from the auth server and include that token in the original API request.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, authentication
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100