We are using the Google Drive .NET SDK to read a bunch of Google Drive folders publicly shared with us to download images for a client of ours. The application is a simple .NET console application that uses an API key with the SDK since we aren't doing any user authentication, etc.
_driveService = new DriveService(new BaseClientService.Initializer()
{
ApiKey = googleApiKey,
ApplicationName = ApplicationName
});
We simply get a list of images from the Google Drive folders and loop through them downloading each image via:
var request = _driveService.Files.Get(fileId);
request.MediaDownloader.ProgressChanged += (IDownloadProgress progress) =>
{
switch (progress.Status)
{
case DownloadStatus.Downloading:
{
break;
}
case DownloadStatus.Completed:
{
our logic here
break;
}
case DownloadStatus.Failed:
{
break;
}
}
};
request.Download(stream);
This was working great until recently we are receiving a DownloadStatus.Failed status and the Exception is a HTML message containing:
<h1>We're sorry...</h1>
<p>... but your computer or network may be sending automated queries. To protect our users, we can't process your request right now.</p></div><div style="margin-left: 4em;">See <a href="https://support.google.com/websearch/answer/86640">Google Help</a> for more information.
Now the error doesn't happen immediately. We can do about 50 requests successfully before that error message starts to appear. We have no idea how long we have to "wait" before we can do another request, but we're out of ideas at this point and very frustrated considering we're using the Google SDK as well as Google API key, which has IP restrictions. Again, we're using an API key, not OAuth since this is a console application, and barely do 1,000 file get requests in a day, which is well below any rate limits. We even tried a one minute delay between file requests, but that doesn't stop the application from receiving the failed status.
Any idea how we can prevent getting this message from a console application, using an API key?