-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Support HTTP Basic Auth for client generation #102
Comments
+1 Is any auth supported? Another person on my team was trying to use swagger-codegen with oauth and no dice their either. |
You can pass headers when running the codegen with the following system property:
So for the password "password", you could simply run btoa("password") to get the basic auth password, and pass it as a header:
That will let you pass any header (including basic auth) to the codegen. When actually using the client, I believe all libraries support passing headers. For example in java: ApiInvoker.getInstance().addDefaultHeader("Authorization", "Authorization:Basic cGFzc3dvcmQ=") |
Thanks. We"ll try this. |
About adding -Dheader="Authorization:Basic cGFzc3dvcmQ=", does it imply the generated API clients would have hard-coded username and password? |
No, this simply applies the header during codegen |
Adding
|
This doen't work for me. I only get this exception: java.io.IOException: Server returned HTTP response code: 401 for URL: |
will make sure this is tested for 2.1.0-m1 |
Hello, I am still getting a Server returned HTTP response code: 401 for URL when I try to generate the java client code. Do you need to provide -auth? |
@keithchong please open a new issue. I'm sure this is supported so perhaps a usage issue. |
Hi Tony, will do. I'm using v2.1.5. |
It isn't possible to create a client if the API is protected with HTTP Basic Auth.
It should be possible to pass the credentials in the URL. Maybe like:
http://user:password@host/api-docs special-key
The text was updated successfully, but these errors were encountered: