Google Drive Error: Registered app required, either through authentication token or key param - google-drive-api

Suddenly today requests from my service attempting to insert a file into Google drive via the Drive API started to receive a 400 error. The error indicates that a registered app is required, full error below. An application was already registered in my Google Cloud console, however the applications name did not match the application name that was used by my service. I renamed the services application name, however the error continues.
400 Bad Request
{
"code": 400,
"errors": [
{
"domain": "global",
"message": "Registered app required, either through authentication token or key param.",
"reason": "required"
}
],
"message": "Registered app required, either through authentication token or key param."
}
Is there something else that needs to be setup, or could this be a delay in the renaming of the service?
EDIT: I'm able to list, update and download files however I cannot insert.

This same issue just started to happen to us today - and we made no changes. I (think I) submitted a bug report to Google about this. Will keep digging..
UPDATE: I created a new project with private key and client ID/email and I get the same error with this new project as well. This appears to be some bug with Google Drive API service.

It happens today on my app too. I guess their service is having problem today

Related

Set up Google Calendar V3 API Push notification via my Google Apps script

I want to use Google CAL API v3 to watch multiple calendars and thus to update all those events from those calendars to a Master Calendar, so I need to use WATCH/PUSH notification in order that whenever there is a new event in those cal’s, those events shd be automatically be pushed/created in my master calendar.
But, I am facing the following issue :Under APIs Explorer. Most of the services return 200 OK, except the Watch request not working.
Services > Calendar API v3 > calendar.events.watch
i got the below request and response
Request
POST https://www.googleapis.com/calendar/v3/calendars/mailid%40domain.com/events/watch?key={YOUR_API_KEY}
{
}
Response
400 OK
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "entity.resource"
}
],
"code": 400,
"message": "entity.resource"
}
}
And then i followed as per the below google documentation
https://developers.google.com/google-apps/calendar/v3/push
Registering Your domain:
Step 1: Verify that you own the domain
Step 2: Register your domain
I verified my domain/notifications in google webmaster tools.
My verified domain look like this:
http://my-domain.com/notifications
And have added my domain name in the webhooks under the PUSH in Google Developer Console, as explained in the doc.
Is there anything i am missing here, plz is there an issue in SSL certificate fr my domain, how can i atleast test in the API explorer, so that i get a return code 200 OK. After that, I need to implement this push/WATCH via Google Apps Script.
Is there any documentation for apps script to use push notification.
Any hint, tip will help me, I am tired with this for the past 1 week in trial and error method.
In the request that you posted the body is empty. In the documentation there is an example where you need to provide the calendar ID, the web_hook and other information:
{
"id": "01234567-89ab-cdef-0123456789ab", // Your channel ID.
"type": "web_hook",
"address": "https://example.com/notifications", // Your receiving URL.
...
"token": "target=myApp-myCalendarChannelDest", // (Optional) Your channel token.
"expiration": 1426325213000 // (Optional) Your requested channel expiration time.
}
Add this information when creating the push notification.
For using apps script you can use URLfetch service with the method "fetch()" then you would need to provide the parameters mentions and make the call as a POST.
Hope this helps.
UPDATE: I will write here to have more space.
Push notifications work in this way.
-You create a push notification with the id, the resource you want to watch, the address where you want to receive the notification and the optional parameters.
-if successful, the server will watch that resource and will send a notification to the address mentioned in the request describing the changes when a change is made to the resource.
-The server needs to know that you received the notification, so from the address mentioned in #1, you need to tell the server that you received the notification returning a HTTP 200 response. (for this you need an app that is listening to the notifications and sending the responses)
for your questions
1.- As the server will make a HTTP request to a url (your web_hook address) Google requires it to be secure, that's why it is required to be HTTPS.
2.- Yes, without that url you won't be able to receive the notification.
3.- Google also needs to verify that the url you provided is actually yours, so you will need to provide the url, then Google will provide you a file, you have to make this file available in that url, then Google will call the url an will retrieve that file. Then you can prove that the URL is yours. I'm not sure if this step can be done with apps script. You can actually deploy a script as web app but i'm not sure if you can use it for this purpose.(here you can find more info and different ways to verify the url)
4.- That's created by yourself. In the documentation is pointed out the recommendations for it.
I hope this clarifies your questions.
You can check here how push notifications work, this example is for Drive but the concept is the same.

Google maps APIs for Business returning error code 403 reason accessNotConfigured

I am using Google Maps APIs for business to get location against Cell IDs and MAC addresses of WiFi access point.
That code was working fine on beta server. Now as I moved to production server, I am getting following response
{ "error": { "errors": [ { "domain": "usageLimits", "reason": "accessNotConfigured", "message": "Access Not Configured. Please use Google Developers Console to activate the API for your project." } ], "code": 403, "message": "Access Not Configured. Please use Google Developers Console to activate the API for your project." } }
In console, Beta server IP was added in allowed IPs. I have added production server IP as well. Still getting above response.
Do I need to generate new key after change in allowed IPs or any other change?
The message is self-explaining activate the API for your project
Go to the console, select the desired project(when you have multiple projects), go to APIs & auth ->API's and activate the service Google Maps Geolocation API

Error 500 when inserting a document in Google Drive with a service account

I need to use Google Drive API to insert and read files in Google Drive from my Java application. I use a service account.
I have created a project in my Google API console, enabled the "Drive API" service, created a new service account, and used the downloaded private key in my application :
GoogleCredential credential = new GoogleCredential.Builder()
.setTransport(HTTP_TRANSPORT)
.setJsonFactory(JSON_FACTORY)
.setServiceAccountId(this.serviceEmail)
.setServiceAccountScopes(DriveScopes.DRIVE)
.setServiceAccountPrivateKeyFromP12File(new java.io.File(this.privateKeyFilePath))
.build();
Then my Drive service is instantiated with :
Drive driveService = new Drive.Builder(HTTP_TRANSPORT, JSON_FACTORY, null)
.setHttpRequestInitializer(credential)
.build();
This works fine, I can insert, share, read files in Google Drive.
My problem is that I created a second project in my Google API console, did the same steps, but can't make it work. My 2 projects look identical, but with the second, I always have an error response when I try to insert a new document :
com.google.api.client.http.HttpResponseException: 500 Internal Server Error
{
"error": {
"errors": [
{
"domain": "global",
"reason": "internalError",
"message": "Internal Error"
}
],
"code": 500,
"message": "Internal Error"
}
}
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:978)
at com.google.api.client.googleapis.media.MediaHttpUploader.upload(MediaHttpUploader.java:237)
at com.google.api.services.drive.Drive$Files$Insert.executeUnparsed(Drive.java:309)
at com.google.api.services.drive.Drive$Files$Insert.execute(Drive.java:331)
The first project has been created 6 months ago, whereas the second (which does not wrok) has been created these days.
How can I get more details about this error ? What can cause this issue ?
This problem can be caused by a bad file format.
Try to upload the file directly in Google Drive and get a more detailed message.
I've had the following message:
"The uploaded file has the wrong format specification - for example, you might be trying to upload a CSV file as a XLS file."
However, I don't know how you can get more details about the error via the API. If anyone knows, let me know!

Daily Limit Error Message with Google Drive

I am getting an error message when trying to use the Google Drive API to get a file. Using Python, the line that causes error is:
file = service.files().get(fileId=googleDriveFileId).execute()
The error message is:
HttpError: <HttpError 404 when requesting
https://www.googleapis.com/drive/v2/files/0B6Cpn8NXwgGPSE8zQW10XzJMc0k?alt=json returned
"File not found: 0B6Cpn8NXwgGPSE8zQW10XzJMc0k">
Basically saying "File not found"
However, if I put the URL being requested into browser, I get a different error message:
https://www.googleapis.com/drive/v2/files/0B6Cpn8NXwgGPSE8zQW10XzJMc0k
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "dailyLimitExceededUnreg",
"message": "Daily Limit Exceeded. Please sign up",
"extendedHelp": "https://code.google.com/apis/console"
}
],
"code": 403,
"message": "Daily Limit Exceeded. Please sign up"
}
}
Neither of these error messages seem correct to me. I know the file is there. Here is a working link to the same file retrieved from "Share Link" in the Google Drive UI:
https://docs.google.com/file/d/0B6Cpn8NXwgGPSE8zQW10XzJMc0k
I have also checked the Quota reports in the api console, and we are at 0% usage.
Any ideas what is going on here?
Thanks
I had similar errors following the python quickstart.
It turned out I had correctly created an API key etc, however had missed step 2:
Select the Services tab in your API project, and enable the Drive API.
Having used the API before I skipped along and missed this crucial point.
Both of the error messages did not have accurate info. The problem was related to permissions. I was using Google Picker to upload the files in question, but these files were not automatically available to the API because of permissions. I thought they would be according to documentation.
I solved problem by setting the permissions for the folder the images are being uploaded to for "Public" using the Google Drive UI. Now my app has permission to access the uploaded files.
While setting files permission to "Public" is okay in my case, as these files are meant to be public, I know this would not be acceptable in all cases. Can someone please shed light on how to handle this problem.... so that files uploaded with Google Picker automatically have the permission to be accessed by the API without setting folder permissions to "Public"?
The messages were accurate.
In the first case, because you don't have permission, Google gives a file not found. This is a standard security measure, rather than leak information by confirming the file exists.
In the second case, you called the API without an Authentication Header, so Google treats you as an unregistered and unauthorised app, which for some Google APIs is OK, up to a a daily quota. In the case of Drive, that daily quota is zero.
I agree it's not intuitive, and I'm sure many developer man years have been wasted (mine included), but it is accurate.
To answer your question about why the uploaded file is inaccessible, check that you have requested the correct scope, and that you are using the correct client id and mime type when doing the upload.

Google Drive authentication issues

I'm having an issue using Google Drive using Ruby.
I can create an OAuth2 client and start making authenticated calls.
I have to query the Google Documents List first in order to fetch a list of files, once I have the file IDs I try to query the Google Drive API like this:
GET https://www.googleapis.com/drive/v1/files/0B9N873iFyYR7MkRfeTAxxxxxxx?access_token=ya29.AHES6ZRckKZ2jZfC6risUtH9ZZxxxxxxxxx
However I'm getting this:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "appNotInstalled",
"message": "The authenticated user has not installed the app with client id xxxxx.apps.googleusercontent.com"
}
],
"code": 403,
"message": "The authenticated user has not installed the app with client id xxxxx.apps.googleusercontent.com"
}
}
This client id refers to an application I created via Google API Dashboard, not the Chrome Web Store.
Anyway I tried to setup a hosted Chrome Web App, configured (and paid) everything to allow a list of test users, but still I get the same error message although the app is installed correctly from the market (not local copy).
With the same client and credentials I'm able to call https://docs.google.com/feeds/ endpoints but not drive ones.
My scopes are rather complete: 'https://docs.google.com/feeds/,https://docs.googleusercontent.com/,https://spreadsheets.google.com/feeds/,http://gdata.youtube.com,plus.me,drive.file,userinfo.email,userinfo.profile'(don't look at the format, it gets fixed automatically afterwards) and they works well.
I'm not using the Drive UI, I just want to use server-side APIs. Thanks for any hints.
Have you set the "api_console_project_id" : "xxxxxxxxxxxxx" argument in your manifest ?
An example is provided here: manifest.json