The Looker API v3.0 has a custom authentication scheme which requires a SHA-1 hash of the query parameters. Does the generated code know how to do this or I need to modify the generated code.
Generating Clients/SDKs Using Swagger Codegen
Hello there!
I’m having a similar problem to
What I mean by response variable whose method is post:
response = self.api_client.call_api(resource_path, 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='User',
auth_settings=auth_settings,
callback=params.get('callback'))
Any thoughts? Thanks!
Solved - disregard 🙂
I am not able to get the GIT.
git clone git@github.com:swagger-api/swagger-codegen.git
It prompts me an error
Cloning into ‘swagger-codegen’…
ssh: connect to host github.com port 22: Connection refused
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
Hey
It sounds like you might have a firewall between your ssh host and github that is blocking traffic on port 22. Try from a location outside of your internal network.
Cheers,
William
William_Lane thanks for the update. This make sense. I shall try via different channel and come back.
But do we have any other way to manually get this configured ?
How and from where do I get the swagger.json file and place the similar as below ?
/Users/scott/Desktop/looker_python_client/swagger.json
I am stuck with this file from few days. Can you help me out?
Cheers
VS
William - thanks for your input this was informative but it didn’t help me completely.
Appreciated. This is going to help me in future thou 🙂
Finally I was able to make till end. Thanks to all support.
Now I am stuck with testing my Looker_Connect.py
when I run the .py code I am getting error as below Help!!!
Traceback (most recent call last):
File “/Users/sv/LookerPython/LKCONNECT2.py”, line 15, in
token = unauthenticated_authApi.login(client_id=client_id, client_secret=client_secret)
File “/Users/sv/LookerPython/swagger_client/apis/api_auth_api.py”, line 122, in login
callback=params.get(‘callback’))
File “/Users/sv/LookerPython/swagger_client/api_client.py”, line 322, in call_api
response_type, auth_settings, callback)
File “/Users/sv/LookerPython/swagger_client/api_client.py”, line 149, in __call_api
post_params=post_params, body=body)
File “/Users/sv/LookerPython/swagger_client/api_client.py”, line 358, in request
body=body)
File “/Users/sv/LookerPython/swagger_client/rest.py”, line 208, in POST
body=body)
File “/Users/sv/LookerPython/swagger_client/rest.py”, line 177, in request
raise ApiException(http_resp=r)
ApiException: (404)
Reason: Not Found
HTTP response headers: HTTPHeaderDict({‘Vary’: ‘Accept-Encoding’, ‘Content-Length’: ‘69’, ‘Content-Type’: ‘application/json;charset=utf-8’, ‘X-Content-Type-Options’: ‘nosniff’})
HTTP response body: {“message”:“Not found”,“documentation_url”:“http://docs.looker.com/”}
Hello
I am stuck with the python script here. when I run the client side I get below error
Traceback (most recent call last):
File “/Users/sv/LookerPython/LKCONNECT2.py”, line 15, in
token = unauthenticated_authApi.login(client_id=client_id, client_secret=client_secret)
File “/Users/sv/LookerPython/swagger_client/apis/api_auth_api.py”, line 122, in login
callback=params.get(‘callback’))
File “/Users/sv/LookerPython/swagger_client/api_client.py”, line 322, in call_api
response_type, auth_settings, callback)
File “/Users/sv/LookerPython/swagger_client/api_client.py”, line 149, in __call_api
post_params=post_params, body=body)
File “/Users/sv/LookerPython/swagger_client/api_client.py”, line 358, in request
body=body)
File “/Users/sv/LookerPython/swagger_client/rest.py”, line 208, in POST
body=body)
File “/Users/sv/LookerPython/swagger_client/rest.py”, line 177, in request
raise ApiException(http_resp=r)
ApiException: (404)
Reason: Not Found
HTTP response headers: HTTPHeaderDict({‘Vary’: ‘Accept-Encoding’, ‘Content-Length’: ‘69’, ‘Content-Type’: ‘application/json;charset=utf-8’, ‘X-Content-Type-Options’: ‘nosniff’})
HTTP response body: {“message”:“Not found”,“documentation_url”:“http://docs.looker.com/”}
Take a look at Step 2 under the “Setup” section.
https://<your_looker_endpoint>:19999/api/3.0/swagger.json
You can retrieve the JSON from the above-mentioned endpoint.
I am getting 404 error similar well not similar its same as mentioned by
raise ApiException(http_resp=r)
ApiException: (404)
Reason: Not Found
HTTP response headers: HTTPHeaderDict({‘Vary’: ‘Accept-Encoding’, ‘Content-Length’: ‘69’, ‘Content-Type’: ‘application/json;charset=utf-8’, ‘X-Content-Type-Options’: ‘nosniff’})
HTTP response body: {“message”:“Not found”,“documentation_url”:“http://docs.looker.com/”}
curl
or wget
: curl -0 https://master.dev.looker.com:19999/api/3.0/swagger.json > swagger.json
.
The response you pasted in here seems to be related to something else. You’re getting a 404, which means the resource you’re looking for is simply not there. Please reach out via help.looker.com or pop on chat so we can have a look at your code.
Scott input was valuable and I was able to get swagger.json not I have moved to next level where I am writing the API script to connect looker via python. I was getting the error. The error is very much similar in early post. But I didn’t see any solution on that but people have overcome this.
to answer second question I even ran the curl via terminal and I get similar error which read as
HTTP/1.1 401 Unauthorized
Content-Type: application/json;charset=utf-8
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
Content-Length: 84
Could you come on chat and we’ll work on this issue with you
Chat would be better. Where can we get connected in chat. ?
I am trying to generate a client using swagger-codegen in aspnetcore
. When I generate the client everything gets generated but all the code in the controllers is filled with TODO comments rather than the actual code for the method:
Example:
public virtual IActionResult Login([FromQuery]string clientId, [FromQuery]string clientSecret)
{
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(200, default(AccessToken));
//TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(400, default(Error));
//TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
// return StatusCode(404, default(Error));
string exampleJson = null;
exampleJson = "{\n \"access_token\" : \"access_token\",\n \"token_type\" : \"token_type\",\n \"expires_in\" : 0\n}";
var example = exampleJson != null
? JsonConvert.DeserializeObject<AccessToken>(exampleJson)
: default(AccessToken);
//TODO: Change the data returned
return new ObjectResult(example);
}
However, when I generate the client using .net starndard, everything gets generated fine and I can consume the API endpoints as documented.
Here is the command I’m running:
swagger-codegen generate -i swagger.json -l aspnetcore -o LookerAPI
Does the swagger file provided by looker (API 3.0) support dotnet core? Seems like it might not be completed yet…
Reply
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.