Hi All,
I am new to swagger & am trying out the features ; thus please excuse my
question if it's already a documented one. I tried looking for information
but could not find any.
I am trying to use the swagger generated client (java using
swagger-codegen-cli-2.1.2.jar) but not able to set the basic authorization
in the header.
My json looks like below to generate the client (same level as basePath and
info) as I want to add the basic authorization to all/global paths.
"schemes":[
"http"
],
"consumes":[
"application/json"
],
"produces":[
"application/json"
],
"securityDefinitions": {
"basicAuth": {
"type": "basic",
"description": "HTTP Basic Authentication."
}
},
"security":{
"basicAuth": []
}
Using the generated client I am setting the username/password as below:
ApiClient apiClient = new ApiClient();
apiClient.setDebugging(true);
apiClient.setUsername(userName);
apiClient.setPassword(password);
UsersApi usersApi = new UsersApi();
usersApi.setApiClient(apiClient);
System.out.println(usersApi.usersUuidStatusGet("1").getStatus());
While generating I have tried both -a "Authorization: Basic
RGV2X09pbVIyUHMzIw==" and without -a as well. The json is local so I am
passing -i
Here is the debug which I see and I get 403
Accept: application/json
User-Agent: Swagger-Codegen/1.0.0/java
--> END GET
<-- HTTP/1.1 403 Forbidden (73ms)
Date: Mon, 15 May 2017 19:40:04 GMT
Content-Length: 0
X-ORACLE-DMS-ECID: 693f4d2b19775a3b:-3adbfc41:15c0d3dfffc:-8000-
0000000000002c50
X-Powered-By: Servlet/2.5 JSP/2.1
OkHttp-Sent-Millis: 1494877204694
OkHttp-Received-Millis: 1494877204708
Am I missing something? Will appreciate any pointers.
Thanks,
Bikash
--
You received this message because you are subscribed to the Google Groups
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.