Trying to use Execution API for one of my project with devMode: true, but getting the following error. But it works flawlessly when I make devMode: false.
NOTE: I am owner and using the API from same account (so it should work ideally)
I have deployed the script as api executable with access as "Anyone"
I have enabled the "Apps Script API" in the developer console
Both the oauth and apps script share the same project
{
"error": {
"code": 404,
"message": "Requested entity was not found.",
"status": "NOT_FOUND"
}
}
I had also experienced the same situation. So can you confirm the following points again?
Save the apps script using the save button again.
Save the apps script as a new version.
Whether the client ID and client secret are retrieved from the project that Apps Script API is used.
Whether the access token is retrieved from these client ID and client secret.
Whether the scope inclues https://www.googleapis.com/auth/drive, https://www.googleapis.com/auth/drive.scripts and https://www.googleapis.com/auth/script.external_request.
After I confirmed above again, I always test using a following curl command. When you use this curl command, please input your access token, function name and script ID.
curl -X POST -L \
-H "Authorization: Bearer ### access token ###" \
-H "Content-Type: application/json" \
-d "{function: '### function name ###',devMode: true}" \
"https://script.googleapis.com/v1/scripts/### script ID ###:run"
In my environment, the error in your question was solved. I don't know whether these can solve your problem. If this was not useful for you, I'm sorry.
Related
I've requested OAuth token with scopes:
https://api.ebay.com/oauth/api_scope/sell.account.readonly and
https://api.ebay.com/oauth/api_scope/sell.account
I generate a new OAuth Application Token for production and attempt to run getPrivileges as such:
curl -H "Authorization: Bearer myOAuthToken" https://api.ebay.com/oauth/api_scope/sell.account
Output is error message:
{"errors":[{
"errorId":1100,
"domain":"ACCESS",
"category":"REQUEST",
"message":"Access denied",
"longMessage":"Insufficient permissions to fulfill the request."
}]}
...but I expect a status return "200 OK". I know this curl call works when doing something like
curl -H "Authorization: Bearer myOAuthToken" https://api.ebay.com/buy/browse/v1/item_summary/search?q=myQuery
so the only thing I can think of is the scopes, but unless I'm mistaken the scopes are appropriate for the getPrivileges call. Am I missing something?
As found in this post there is a special clause that this call requires a token that was specifically generated through the authorization code grant flow. Instead of generating an OAuth straight from my User Tokens page, I walked through the grant flow and generated a token and it works.
We are using the Google Drive API to perform certain file-related operations in our application. One of our use cases is to change particular folders owner.
I have return below code to perform this action
Permission permission = new Permission();
permission.setRole(Permission.OWNER.getRole());
permission.setType(Permission.OWNER.getType());
permission.setEmailAddress(email);
googleDrive.permissions()
.create(fileId, permission)
.setSendNotificationEmail(false)
.setTransferOwnership(true)
.execute();
When attempting to change the owner, we got an error from Google.
{
"error": {
"errors": [
{
"domain": "global",
"reason": "forbidden",
"message": "Forbidden"
}
],
"code": 403,
"message": "Forbidden"
}
}
We have checked errors listed here at https://developers.google.com/drive/web/handle-errors. But, I didn't found any error with above detail.
When I have attempted to change ownership of a particular file using the same code, it worked fine.
Does anyone have any idea on what I'm missing or what might be the issue?
Also, the same works when I've used cURL to change folder ownership
curl POST \
'https://www.googleapis.com/drive/v3/files/[FILE_ID]/permissions?transferOwnership=true' \
--header 'Authorization: Bearer [ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{"role":"owner","type":"user","emailAddress":"[EMAIL]"}'
Forbidden
Normally means that the user you are logged in with does not have the access themselves to do what you are trying to do. So in order to change the owner i would suspect that you would need to have write access to that file or be the owner of the file itself.
For example i cant login and change the owner on a file that you own I dont have enough access to the file.
You may also want to check the scope you are authenticating with.
I want to start a notebook server as described here. I learnt that I need to get an auth token from this and so wanted to get the same, I have to use the api as described here. It always states "Method not allowed, 405". I am unable to figure out what is the right way to do this.
I tried the following post requests:
http://MY_JHUB_ON_K8S_SERVER.com/authorizations/token
with the body of JSON/Application:
{
"username": "aviral",
"password": "aviral",
}
The headers are:
[{"key":"Content-Type","name":"Content-Type","value":"application/json","description":"","type":"text"}]
In Postman, I had tried basic auth as well as no auth. In the basic auth, I pasted the username and password, while when there was no auth, I put the same in the json body
I expect to get the token so that I can start a server. Right now, regardless of the permutation and combination, I am getting 405.
This seems to be possible using the oath api endpoint but I wasn't successful.
Instead I run this command on the jupyterhub server to generate a token
jupyterhub token myusername
and then calls should work properly using the rest api:
curl --insecure 'https://myjupyterhubserver:8443/hub/api/users' \
-H 'Authorization: Token mygeneratedtoken'
I am currently trying to update the user permissions on a project with the function PATCH: project / users (v2) for several services (BIM Docs, Field, Glue, Plan and Schedule) but for other services that Docs I have an error telling me that the services are invalid.
Code documentation here.
When I put only the permissions for project administration and Docs, it works.
However, i want to use the other services. So, when I set permissions for Docs, the rights for others are removed.
After several searches, I can't find a way to perform this command in cURL.
Here is the content:
curl -H "Content-Type: application/json"
-H "x-user-id: %user_admin_id%"
-H "Authorization: Bearer %TOKEN%"
-X PATCH https://developer.api.autodesk.com/hq/v2/accounts/:account_id/projects/:project_id/users/:user_id
-d '{
"services":
{"document_management":{"access_level":"user"},
"field_management:{"access_level":"user"}
},
"company_id":"%company_id%",
"industry_roles":["0b74b631-0a08-49ad-8f44-ada57d7de051"]
}'
Here the error :
"error":[{"message":"Invalid services
[\"field_management\"]","code":2000}]
I already tried field instead field_management.
Any solutions ?
Thanks.
You can not set permission through API, yet.
You can set a service to a project:
https://developer.autodesk.com/en/docs/bim360/v1/reference/http/projects-POST/
services-type parameter.
You also need to have a license to those sub services.
I want to use Oauth2 and Spring-security with rest web service. I am new for this, i am trying to create configuration with the help of some websites. Still, i clearly not understand how and what is the flow for oauth authenticate for rest service. i am using latest dependencies Click on the link for see my configurations. I am using database for store clients information and tokens. when i trying to access the token, using follwoing url with post request and post body:
http://localhost:8080/empirecl-api/oauth/token
grant_type=password&username=a#a.com&password=password&client_id=my-client-with-secret&client_secret=ak_secret
The basic authentication pop-up box will appear. I am using chrome rest postman client. I have user table in my database where i store, username and password, when i enter those username and password, the authentication fail, If i use i my client_id and client_secret as a username and password, the authentication is fail. When i cancel the pop of basic authentication following json is return:
{
"error": "unauthorized",
"error_description": "No client with requested id: a#a.com"
}
I am unable to figure out what will happen.
When i trying to access following url with get reqquest:
http://localhost:8080/empirecl-api/oauth/authorize?grant_type=password&username=a#a.com&password=password
The following error will return:
{
"error": {
"error": "invalid_client",
"error_description": "Bad client credentials"
}
}
When i check the error in console, of eclipse, the follwoing error is display:
AuthorizationEndpoint:436 - Handling ClientRegistrationException error: No client with requested id: null
How i resolve this problem and how to use Oauth with my rest api. I also want to secure my all rest url with Oauth.
There are a couple of things wrong here.
You are using the wrong endpoint - the request should be to the token endpoint, not the authorization endpoint.
It should be a POST request - you shouldn't be passing the parameters in the URL
You are confusing when the user has to authenticate and when the client does - the server was looking for Basic credentials from the client but you were entering the username.
See the oauth2 spec section on using the resource owner password grant.
The client needs to authenticate and, as porterhead points out, you can do this using Basic authentication. The spec does also allow passing of the client id and secret as post parameters, but prefers Basic authentication.
You should probably make sure you understand a bit more about how OAuth2 works, and perhaps expand your question to explain why you want to use it and why you've chosen this particular grant type.
You need to pass your client username and password as a Base64 encoded Authorization header.
Try using curl. Here is an example:
curl -v -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Basic MzUzYjMwMmM0NDU3NGY1NjUwNDU2ODdlNTM0ZTdkNmE6Mjg2OTI0Njk3ZTYxNWE2NzJhNjQ2YTQ5MzU0NTY0NmM=" \
'http://localhost:8080/empirecl-api/oauth/token?grant_type=password&username=a#a.com&password=password'
I have a working example described here