Drive service account returns 403 usesLimits

I’m trying to write an AppEngine application that writes a Google document to Google Drive, places it in a specific set of folders and sets permissions. I have work with the old DocsList API, but since this is just deprecated, I decided to update my code (and I had some additional functions to add anyway).

The problem I am facing is this: when I use a service account and try to impersonate a specific user, I get 403 with usage restrictions, although I have not used any of my quotas.

Here is the code I'm using:

GoogleCredential credentials = new GoogleCredential.Builder() .setTransport(HTTP_TRANSPORT) .setJsonFactory(JSON_FACTORY) .setServiceAccountId("xxxxxxxxxxgserviceaccount.com") .setServiceAccountScopes(DriveScopes.DRIVE) .setServiceAccountPrivateKeyFromP12File( new java.io.File("xxxx-privatekey.p12")) .setServiceAccountUser(" user@xxxxxx.org ").build(); 

I than use these credentials to initialize my Drive object:

 Drive d = Drive.builder(httpTransport, jsonFactory) .setHttpRequestInitializer(credentials) .setJsonHttpRequestInitializer(new JsonHttpRequestInitializer() { @Override public void initialize(JsonHttpRequest request) { DriveRequest driveRequest = (DriveRequest) request; driveRequest.setPrettyPrint(true); } }).setApplicationName("MYAPPNAME").build(); 

BTW: I tried using a new disk (....), but it just won’t work, no matter what. Saves errors in that no internal methods were found!

Back to this problem: When I use "d" to call something like .files (). Get ("SOMEFILEID"). Execute () I get 403

 { "code" : 403, "errors" : [ { "domain" : "usageLimits", "message" : "Daily Limit Exceeded. Please sign up", "reason" : "dailyLimitExceededUnreg", "extendedHelp" : "https://code.google.com/apis/console" } ], "message" : "Daily Limit Exceeded. Please sign up" } 

I can’t understand why this is not working. I watch online all day, but cannot find a suitable answer. Some help is much appreciated.

+4
source share
2 answers

Usually I get 403 when the HTTP authorization header is missing in the API call. Trace the http and look at the headers. The rationale for the "quota" message is that without the Auth header, you are anonymous, and the quota for anonymous use is zero.

You can also verify that your application is registered for both Drive APIs, as I heard that this can cause the same problem.

In an internal method problem, it sounds like you are using incompatible versions of libraries. For me, the best thing was to remove all the libraries that I downloaded using the sample code, and then use the Google Eclipse plugin for the "Google / Add Google API ..." to download all the latest versions.

+1
source

So the pinoyyid answer helped, although it was not the final answer.

I decided to solve this as follows:

I took my AppID (xxxxx.apps.googleusercontent.com) and added it to my CPanel https://www.google.com/a/cpanel/[►YOURDOMAIN††/ManageOauthClients with these areas:

After that, I was able to make an authenticated request for the Drive environment. Now the stack had various problems, but 403 were resolved.

+2
source

All Articles