Skip to content

[JAVA] OAuth2 ClientCredentials Java code not being generated to retrieve token #404

@Morac2

Description

@Morac2
Description

Java code to retrieve clientCredentials from tokenURL serve is not be generated from an OpenApi 3.0.1 YAML file. Code is generated to add the bearer authorization to the requests, but there is no code to retrieve the authorization so OAuth2 doesn't work. Nothing is added to the DefaultApi.java file regarding retrieving the token. Note the tokenUrl is not the issue as I've tried replacing that with a full URL as opposed to a path, but the generated code doesn't change.

openapi-generator version

Tried all versions from 3.0.2 to 4.0.0-SNAPSHOT

OpenAPI declaration file content or url
components:
  securitySchemes:
    accessCode:
      type: oauth2
      flows:
        clientCredentials:
          tokenUrl: /oauth/token
          scopes:
            write: allows modifying resources
            read: allows reading resources
            upload: allows upload streams
            download: allows downloading streams

Here's the full YAML file: https://gist.githubusercontent.com/Morac2/6f52e785543944b7393d88cc64bfd457/raw/8b39cd6308d750f720f7252e83e2e243d6c037be/test.yaml

Command line used for generation

java -jar openapi-generator-cli.jar generate -l java -i file.yaml -o out_dir

Steps to reproduce

Simply use openapi-generator-cli to generate code.

Related issues/PRs

N/A

Suggest a fix/enhancement

I don't have a suggested fix as I don't know why the code to grab the token isn't being created.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions