swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

Example of authorization is needed (CLI) and no debug option to see what goes wrong (401 response)

Open ThePlenkov opened this issue 6 years ago • 3 comments

Dear devs,

I'm trying to make docker image (CLI mode) working for our service (secured with basic auth)

However is not very clear what to put inside -a parameter.

I tried all possible combinations: only base64 token, token with Basic in front, full string Authorization: Basic ... nothing worked - all the time 401 back. May be good example will be useful.

Meanwhile I would really love to see instead of Java stack some meaningfull trace results like for example curl-like request printed out with headers. It will significantly help to analyze what goes wrong.

Do you have any ideas is it possible within current version?

Thank you!

ThePlenkov avatar May 20 '20 10:05 ThePlenkov

Potentially related: https://stackoverflow.com/a/42137322

I too have found this very challenging given there isn't an example provided.

Also cross posting to https://github.com/OpenAPITools/openapi-generator/issues/6745

johnthagen avatar Jun 22 '20 12:06 johnthagen

Hello; this plagued me for a full day using openapi-generator. I did get it to work with the following steps. TL:DR for basic auth for anyone showing up here:

  1. base64 encode your username:password (e.g. admin:admin)
  2. append that string to Basic (note the space!) and url encode that
  3. append that to Authorization: to arrive at...
$ > openapi-generator generate -a Authorization:Basic%20YWRtaW46YWRtaW4%3D ...

cdanielsen avatar Jun 26 '20 06:06 cdanielsen

+1.

An actionable documentation must be more than vague descriptions, e.g., the current -a/--auth doc only has "adds authorization headers when fetching the swagger definitions remotely. Pass in a URL-encoded string of name:header with a comma separating multiple values", a viable documentation should include worked examples.

haokanga avatar Jul 09 '20 15:07 haokanga