OpenAPITools / OpenAPITools/openapi-generator
[REQ] OAuth2 addition to get access token for client credentials grant type -- java client sdk
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
we have a requirement to get access token before making a request to an external API. The external API supports oauth2 client credentials grant type. We generated a client sdk via OA gen using java and default library (okhttp3).
Their reqs to get the access token is to pass in the client id and secret as basic auth.
Example
$ curl -i -H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Authorization: Basic c3FIOG9vSGV4VHoAyg5T1JvNnJoZ3ExaVNyQWw6WjRsanRKZG5lQk9qUE1BVQ' \
-X POST 'https://docs-test.apigee.net/oauth/accesstoken' \
-d 'grant_type=client_credentials'
Apigee for example does actually state on their site:
You must pass the Client ID and Client Secret either as a Basic Authentication header (Base64-encoded) or as form parameters client_id and client_secret. You obtain these values from the registered developer app associated with the request.
But unfortunately they only handle if you pass in as basic auth (base64 encoded) and not as form params.
Describe the solution you'd like
The retry oauth logic actually passes in the client id and secret as body params. Solution is to handle the alternative which is to pass in as basic auth when getting the access token.
Describe alternatives you've considered
Additional context
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
Start by locating the Java client SDK's retry OAuth logic and its access-token request path; the issue identifies the default okhttp3 library and client-credentials grant as the relevant entry points. Check how credentials are currently placed in form parameters, then verify the generated client can send them as a Base64 Basic Authorization header while retaining the existing grant_type behavior.
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