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

[BUG] java native: oauth files not being generated #8702

Open
4 of 6 tasks
shavo007 opened this issue Feb 15, 2021 · 7 comments
Open
4 of 6 tasks

[BUG] java native: oauth files not being generated #8702

shavo007 opened this issue Feb 15, 2021 · 7 comments

Comments

@shavo007
Copy link

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

oauth files not generated for java native http client

openapi-generator version

5.0.1

OpenAPI declaration file content or url
components:
  securitySchemes:
    bpay_auth:
      type: oauth2
      flows:
        clientCredentials:
          tokenUrl: https://sandbox.api.bpaygroup.com.au/oauth/token
          scopes:
            read:validate-payment: BPAY payment validation API

(for YAML code) or

# native http client supported in java 11
generatorName: java
outputDir: samples/client/bpay/java/native
library: native
additionalProperties:
  artifactId: bpay
  hideGenerationTimestamp: "true"
  dateLibrary: "java8"
  httpUserAgent: "Shane-Bpay-Java/1.0.0"
  modelPackage: "com.shane.bpay.models"
  apiPackage: "com.shane.bpay.api"
  groupId: "com.shane"
Generation Details
    $SWAGGER_CMD generate \
        --input-spec "./bpay-oas.yaml" \
        -g "$1" \
        --config "./swagger-config/config-$1.yaml"
Steps to reproduce

If i change to another client like the default, then i see the oauth files

Related issues/PRs

#6284

Suggest a fix
@shavo007
Copy link
Author

i also tried with the latest snapshot OPENAPI_GENERATOR_VERSION=5.1.0-SNAPSHOT

@wing328
Copy link
Member

wing328 commented Feb 16, 2021

Likely the OAuth is not yet supported in the Native client. May I know if you've time to contribute a fix by copying the template from other clients (http libraries) ?

jersey2 should have pretty good Oauth support (e.g. automatic token refresh, etc)

@shavo007
Copy link
Author

thanks @wing328 i think i was thrown off as the readme doc generated for native in the example had OAuth. So was not sure if it was supported or not.

The default which is okhttp supports oauth and looks good setting access token. I havent looked into the impl yet around refresh and how that works. is there an example in the repo of RetryingOAuth?

Realistically, im a bit swamped with meetings at the moment so cant commit anytime. I might see if my team has capacity to investigate.

      // google-api-client doesn't use the OpenAPI auth, because it uses Google Credential directly (HttpRequestInitializer)
            if (!(GOOGLE_API_CLIENT.equals(getLibrary()) || REST_ASSURED.equals(getLibrary()) || usePlayWS
                    || NATIVE.equals(getLibrary()) || MICROPROFILE.equals(getLibrary()))) {
                supportingFiles.add(new SupportingFile("auth/OAuth.mustache", authFolder, "OAuth.java"));
                supportingFiles.add(new SupportingFile("auth/OAuthFlow.mustache", authFolder, "OAuthFlow.java"));
            }

Im guessing these are the libs that do not support oauth right now?

@shavo007
Copy link
Author

Configuration.setDefaultApiClient(new ApiClient(clientId, clientSecret, parameters));

i believe this then incorporates the retry mechanism. Will test it out.

@one1note
Copy link

one1note commented Mar 8, 2021

Any update on this issue?

@megha-babar
Copy link

Any update on this ?

@zenyuk
Copy link

zenyuk commented May 4, 2022

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants