I am trying to upload a file using python to google drive.
I started with the quick start shown here:
https://developers.google.com/drive/api/v3/quickstart/python
Ive created the oAuth 2 client id and downloaded the credentials json file to my project folder.
However when I try to run the code, when it opens the browser to confirm I receive the following error:
Error: restricted_client
Unregistered scope(s) in the request: https://www.googleapis.com/auth/drive
Request Details
That’s all we know.
Ive tried changing the scope from
SCOPES = 'https://www.googleapis.com/auth/drive.metadata.readonly'
to
SCOPES = 'https://www.googleapis.com/auth/drive'
however I get the same error
I have also tried making a new credential and client id, still get the same error
can anyone please point out what I am doing wrong?
Update: at 18:18 UTC
Seems that it was an issue on googles end and now seems to be working again. I launch my python code and a browser window opens asking me to log in. I can log in and receive the message:
The authentication flow has completed.
Hope everyone else is able to get theirs working as well
This issue seem to be at Google's end . I faced similar issue with java SDK and many others have reported same issue today only while using YouTube API.
Related
I've been unable to access the source code for any of my Cloud Functions across multiple Google Cloud Projects for well over a week. When clicking through to the Source tab of a function I see a greyed out area with the message "Unknown error while fetching the archive".
On clicking Edit I'm met with "We can't display source code of this function." The error persists even if I try to set up a new Cloud Function. Then I get an error with no accompanying message.
There doesn't seem to be any issue with billing, I've tried logging in as a different user and I'm unable to find any documentation online. Has anyone been able to resolve this successfully?
In most scenarios, this error arises due to billing issues related to the account. However, since you confirm your case is not so, I suggest you try logging in with an incognito window once.
If it doesn't help, make sure to try out the steps mentioned in here.
I am using Legacy free edition of G Suite account to run my web application. What I want to achieve is to force users to log in. So I deployed the web application with these settings
Execute as User accessing the web app
Who has access Anyone with Google account
Now I was able to identify the user accessing the web application - I got their email from Session.getActiveUser().getEmail(); perfect. Then I want to save all their "data" in 'their own' spreadsheet. When I save a file using DriveApp.createFile(fileName, 'Hello, world!') the file is save on their Google disc. I want all the application data to be on my disc.
So I created a new project - library - and deployed as library and passed it the email because it will be the file name. It works if I access the web as me - owner of both projects. If I access the web as someone else I got this error We're sorry, a server error occurred while reading from storage. Error code NOT_FOUND.
Then I deployed the library as a web application with these settings
Execute as Me
Who has access Anyone or Anyone with Google account
again if I access the web as the owner it works but someone else gets an error Library with identifier tmplib is missing (perhaps it was deleted, or maybe you don't have read access?)
Also there is no log. Just error. Actually there are no logs from the library - I used Logger.log() and console.log()
I tried to add the library from the old editor as there was some error reported in past that might cause such error.
Is there any way I can use an web app and library intended way so the file is always saved as me?
UPDATE
If I share the library using share button and anyone is Editor then the web user needs to give permission to the web application to access their Drive and the file is saved in their Drive. I want ALWAYS the file to be saved in my Drive.
This appears to be a bug!
There is already a report on Google's Issue Tracker which detail the same kind of behaviour:
Error when including library
You can also hit the ☆ next to the issue number in the top left on the aforementioned pages which lets Google know more people are encountering this and so it is more likely to be seen to faster.
i've been learning with google app script, and tried to make a web form because of the limitation of google form. I tried making it by following this example, and it works. However when I tried using incognito or other browser without a google account log on to it, it failed, showing this error
"Maaf, terjadi error pada server saat membaca dari penyimpanan. Kode error INTERNAL."
Which is in Indonesian that basically states the server failed to read the file, and there is an internal error. This is the web app script.
Settings for the web app deployment
Also in the spreadsheet linked is set to anyone with link is able to edit. When this is changed to anyone with link is able to view only, causes a log in prompt to appear in incognito mode.
Any help is greatly appreciated. I also found out earlier that this problem occurred previously because of a bug by google, but it has been resolved. So did I do something wrong?
According to the Apps Script Web Apps documentation:
The first is labeled Current web app URL and ends in /exec. This URL is for the published version of your app, based on the last version you saved and deployed.
The second is the link labeled latest code and ends in /dev. This URL can only be accessed by users who have edit access to the script. This instance of the app always runs the most recently saved code — not necessarily a formal version — and is intended for quick testing during development.
Therefore, when sharing the web application, you should be sharing the /exec link.
There is an open bug for this: https://issuetracker.google.com/issues/160665120
I found plenty of questions regarding this issues, but no one answer that could solve my problem.
I have a project in Apps Script, which I deployed as API executable. I enabled Google App Script Execution API. I made OAuth 2.0 Client ID on developer console. I made everything step-by-step as described here: https://developers.google.com/apps-script/guides/rest/api
Then I try to execute code from Google API Explorer: https://developers.google.com/apis-explorer/#p/script/v1/
I fill in request body properly, fill in script id (take it from "File > Project properties" from App Script editor), but what I get is "Permission denied":
Well, I tried to do the same from PyCharm (Python). I fully followed the following instruction: https://developers.google.com/apps-script/guides/rest/quickstart/python
Guess, what I got... The same error!
The Apps Script project is saved in my corporate Google Drive. The scopes of the project are: https://www.google.com/calendar/feeds https://www.googleapis.com/auth/script.external_request , which I filled in correctly in Python and shouldn't fill in in API Explorer.
Many users recommend to check if the project is correctly associated with a project on Google Cloud Platform. When I try to change project, I get error: "The project number should not match." Probably because it is associated correctly...
I almost lost my hope... Again, I saw a lot of answers to this issue across StackExchange forums, but no one could have solved this problem.
One more note: I didn't sign up for the Google Cloud Platform (I don't have a work account there, although it sees my projects and I could have generated OAuth2 2.0 Client ID and API key.
Well, I deleted my python project along with the .credentials file and recreated the project - then it worked. So probably it didn't work, because I missed one of described steps at the first execution of the code and after I fulfilled all the requirements I went on using old creds.
So for all who faces the same problem:
Do everything what is described in the Google documentation and my question.
If you missed something, delete the .credentials file and run the code again. Then it should work.
I am trying to run Google Drive API using Google Client V3 in PHP. I have credentials for my locahost site set up, have downloaded the JSON and load the client with those credentials and on my local site everything works fine.
When I move it to the live site and download the JSON for the the project we use on the live site I keep getting a redirect_uri_mismatch. I've checked the console for this project and the redirect uri's are set correctly. I have the following for redirect uri
https://www.awesomestories.com/Google/getClient
https://awesomestories.com/Google/getClient
https://www.awesomestories.com/Google/getClient/
https://awesomestories.com/Google/getClient
I realize this is over kill but I wanted to make sure every possible version was set to eliminate this as the problem. The Google prompt is happening and when the code is returned and I try to to load the code parameter into Google client:
$resp = $client->authenticate($_GET['code']);
I get the following response
array(3) {
["error"]=>
string(21) "redirect_uri_mismatch"
["error_description"]=>
string(11) "Bad Request"
["error_uri"]=>
string(0) ""
}
The url that it is being redirected to is
https://www.awesomestories.com/Google/getClient
Which matches what is set in the console. Also we use this same project's credentials on the site already although we are just using the API key associated with this project not the Oauth2 credentials which GoogleClient is using. So for this project this is the first time we are using the Oauth2 credentials set up in the Google Console. I just can't figure out why the authentication is succeeding on the test site but not on the live site.
Another thing that is strange is that initialization of the client looks like this:
$client = new Google_Client();
$client->setAuthConfigFile(SYSTEM_PATH.'/shared/php/google-api-php-client/client-prod.json');
$client->setAccessType('offline');
$client->setApprovalPrompt("force");
$client->setPrompt("consent");
and on my local site when the google prompt authorization screen comes up it asks to allow offline access, but on the live site it never asks to allow offline access.
If someone could point me to what is going wrong I would really appreciate it.
So I don't know why this worked, but it did. I removed all the redirect uris from my console with the project associated with this, ran my code and at prompt screen got a redirect mismatch uri error as expected, I then re added the redirect uris, copying the one from the error message displayed on the prompt and then ran my code and the call succeeded. The strange thing is that the redirect I copied from the error message was the same that was in there before, because I copied the ones I deleted and compared them so I have no idea why this worked. Also before when I set the Google Client with the redirect uri the prompt screen went through fine without a hitch it was only when trying to load the authorization code sent back from Google prompt screen that the uri mismatch error would show up. I've ran Google prompts before where the redirect uri was set incorrectly on the client and this error appears in the prompt screen, so I'm not positive what was going on here, but it now is working.