It looks like Google made some changes today (February 5, 2020) that impacted several of my scripts. The UrlFetch directly to drive.google.com stopped working (error 403 / forbidden) and can not access a file that is flagged public.
UrlFetchApp.fetch("https://drive.google.com/uc?export=download&id=<<file id>>")
A.) working: This file link from a browser works when you click the link
https://drive.google.com/uc?export=download&id=1qNBgV2t-D5n_ut-4QINMhKg6ZJXt2-VZ
B.) failed: The URLFetch to the same url failed after February 5
var DataSet = UrlFetchApp.fetch("https://drive.google.com/uc?export=download&id=1qNBgV2t-D5n_ut-4QINMhKg6ZJXt2-VZ").getContentText();
Error: We're sorry...... but your computer or network may be sending automated queries. To protect our users, we can't process your request right now. See https://support.google.com/websearch/answer/86640
Redirect
I noticed that The above url is redirected to the url below. When I use the url below it does work in the script.
https://doc-0g-9k-docs.googleusercontent.com/docs/securesc/ha0ro937gcuc7l7deffksulhg5h7mbp1/9hd91fs45kj9n2qh7nsvhpacnt7pok06/1580978700000/15098391250088696476/*/1qNBgV2t-D5n_ut-4QINMhKg6ZJXt2-VZ?e=download
Q: So the conclusion is that the redirect stopped working and throws in an error message. Additional Security measures are great but it's bummer when a vital part of a script breaks.
What would you recommend when multiple users (scripts) need anonymous access to a file in drive?
wkr,
Moosy
I don't care about permissions and just want the file to be public to the world without any authentication or authorization.This was working with UrlFetchApp for several years and broke with V8 and the 'new security policy'.
Work around (DriveApp):I 'solved' it for now by using the DriveApp service but this is an authorization my users really don't like !!!!
var DataSet = DriveApp.getFileById("1qNBgV2t-D5n_ut-4QINMhKg6ZJXt2-VZ").getBlob().getDataAsString();Original line (UrlFetchApp):
var DataSet = UrlFetchApp.fetch("https://drive.google.com/uc?export=download&id=1qNBgV2t-D5n_ut-4QINMhKg6ZJXt2-VZ").getContentText();
Any other suggestion how to avoid using DriveApp just to fetch a public file from Drive is very welcome !!!
Thanks,M
On Thursday, February 6, 2020 at 2:00:36 PM UTC+1, aj.addons wrote:You could programmatically grant sharing permissions to specific users instead of making the file public to everyone. But, whether that would fix the error, I have no idea.The DriveApp service does have a getDownloadUrl() method on the file class.Are you building the download url with a string formula?On Thursday, February 6, 2020 at 12:37:45 AM UTC-5, Moosy Research wrote:It looks like Google made some changes today (February 5, 2020) that impacted several of my scripts. The UrlFetch directly to drive.google.com stopped working (error 403 / forbidden) and can not access a file that is flagged public.
UrlFetchApp.fetch("https://drive.google.com/uc?export=download&id=<<file id>>")
A.) working: This file link from a browser works when you click the link
https://drive.google.com/uc?export=download&id=1qNBgV2t-D5n_ut-4QINMhKg6ZJXt2-VZB.) failed: The URLFetch to the same url failed after February 5
var DataSet = UrlFetchApp.fetch("https://drive.google.com/uc?export=download&id=1qNBgV2t-D5n_ut-4QINMhKg6ZJXt2-VZ").getContentText();
Error: We're sorry...... but your computer or network may be sending automated queries. To protect our users, we can't process your request right now. See https://support.google.com/websearch/answer/86640Redirect
I noticed that The above url is redirected to the url below. When I use the url below it does work in the script.
https://doc-0g-9k-docs.googleusercontent.com/docs/securesc/ha0ro937gcuc7l7deffksulhg5h7mbp1/9hd91fs45kj9n2qh7nsvhpacnt7pok06/1580978700000/15098391250088696476/*/1qNBgV2t-D5n_ut-4QINMhKg6ZJXt2-VZ?e=download
Q: So the conclusion is that the redirect stopped working and throws in an error message. Additional Security measures are great but it's bummer when a vital part of a script breaks.What would you recommend when multiple users (scripts) need anonymous access to a file in drive?
wkr,
Moosy
--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/bcdc4e64-a3c8-452d-88e9-e85a27fa624e%40googlegroups.com.
function Demo(){
var ipa = JSON.parse(UrlFetchApp.fetch("http://ip-api.com/json?fields=query").getContentText()),
uri = 'https://drive.google.com/uc?export=download&id=1qNBgV2t-D5n_ut-4QINMhKg6ZJXt2-VZ',
opt = {'muteHttpExceptions' : true};
Logger.log('IP Address = ' + ipa.query);
Logger.log('HTTP Response code = ' + UrlFetchApp.fetch(uri,opt).getResponseCode() );
Logger.log('HTTP Output = ' + UrlFetchApp.fetch(uri,opt).getContentText() );
}
--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/19d188a2-06ac-4d90-9ef7-e6e050755d44%40googlegroups.com.