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][csharp-netcore] bearerAuth is interpreted as basicAuth #5915

Closed
FaFre opened this issue Apr 13, 2020 · 4 comments · Fixed by #5921 or #6136
Closed

[BUG][csharp-netcore] bearerAuth is interpreted as basicAuth #5915

FaFre opened this issue Apr 13, 2020 · 4 comments · Fixed by #5921 or #6136

Comments

@FaFre
Copy link
Contributor

FaFre commented Apr 13, 2020

Description

I added a bearer authentication in my description according to the the swagger docs:

"components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    }
...
"security": [
    {
      "bearerAuth": []
    }
  ]

But for some reasons the generated code contains an basicAuth with username/password instead of the bearer expected as Authorization: Bearer <token>:

DefaultApi.cs:

// authentication (bearerAuth) required
            // http basic authentication required
            if (!String.IsNullOrEmpty(this.Configuration.Username) || !String.IsNullOrEmpty(this.Configuration.Password))
            {
                localVarRequestOptions.HeaderParameters.Add("Authorization", "Basic " + Org.OpenAPITools.Client.ClientUtils.Base64Encode(this.Configuration.Username + ":" + this.Configuration.Password));
            }
openapi-generator version

I use the docker image:

$ openapi-generator-cli version
4.3.1-SNAPSHOT
OpenAPI declaration file content or url

Gist

Command line used for generation
docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli generate -i https://gist.githubusercontent.com/FaFre/b15e59572a974a9f453d14e5cdaf3bec/raw/d40a46cb20d70dd41abbf19691745f2ffb5a1f04/test.json -g csharp-netcore -o /local/
@FaFre FaFre changed the title [csharp-netcore] bearerAuth is interpreted as basicAuth [BUG][csharp-netcore] bearerAuth is interpreted as basicAuth Apr 13, 2020
@wing328
Copy link
Member

wing328 commented Apr 14, 2020

@FaFre thanks for reporting the issue. I've filed #5921 to fix it.

@codemnk
Copy link
Contributor

codemnk commented May 1, 2020

Looks like it is still not fixed in async client

@wing328
Copy link
Member

wing328 commented May 2, 2020

@codemnk my bad that I missed it in my previous PR. I've filed #6136 to fix it.

@wing328
Copy link
Member

wing328 commented May 4, 2020

@codemnk the fix has been merged into master. Please give it another try.

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