Getting Server Rejected error when upload using Google Picker, Oauth2

We are trying to use google.picker to have our users upload files to our drive account (i.e., the user is not required to have a Google account to upload).

We're trying to use regular Google accounts as application-owned accounts and got our AUTH_TOKEN using OAuth2 and set it using .setOAuthToken(AUTH_TOKEN) . We followed everything described in the docs.

However, when uploading, we got a Server Rejected error. The call to https://docs.google.com/upload/resumableupload?authuser=undefined returned:

{"errorMessage":{"reason":"REQUEST_REJECTED","additionalInfo":{"uploader_service.GoogleRupioAdditionalInfo":{"completionInfo":{"status":"REJECTED"},"requestRejectedInfo":{"reasonDescription":"agent_rejected"}}},"upload_id":"AEnB2Ur64Gb0JDCk_8mg5EhpdcaqL82wBQHumHjcGvDqYibtksmUzhfhBolsmBFzRuvQPRyi43SYfactJZvIWYrQ6xAqzu3L9g"}}

We know we cannot use service accounts since the picker doesn't support it.

Do we miss something in getting the AUTH_TOKEN? Do we need to something in the console?

Answers


Give us a little more code, or check the call to gapi.auth.authorize()
  1. Check that you are using the correct scope to obtain the OAuth token.
  2. Double-Check the scope declaration:
  3. Check the call to gapi.auth.authorize()

    window.gapi.auth.authorize(
    {
         'client_id': clientId,
         'scope': scope,
         'immediate': false
    },
    handleAuthResult);
    

    from: https://developers.google.com/picker/docs/#hiworld

Without an actual code sample, it is very difficult to say exactly what is going on. Most likely it is the auth token colection. However, it may also be something as simple as not defining a google User (clientID) which in turn impacts the gapi.auth.authorize() call.


maybe this thread can help you: https://groups.google.com/forum/#!topic/Google-Picker-API/PPd0GEESO78 It is about setting the oauth context

or this one: https://productforums.google.com/forum/#!msg/drive/GDl4uBkkbxM/jRejcxI-EV8J It is about the type of file you try to upload with autoconvert on..


Use a Google Apps script on Drive with the function doPost to send data to the server. Then write to file with the Drive API. On publish, you have to set the permissions to "accessible to anyone, even anonomous" if doing cross-domain calls. Make the script run under your user name in Google (for testing), but most likely you would want that function moved onto some application-user account in Gmail.

If you need a level of authentication involved, even if the script is made public, you may authenticate against a CloudSQL hosted database and/or with the Jdbc library to connect to an external resource.


The Scope seems to be the problem.OAuth Token must be obtained using correct scope only: http://tinyurl.com/ldotq4y


Easily replace scope: 'https://www.googleapis.com/auth/drive.readonly' to scope: 'https://www.googleapis.com/auth/drive' . So that you're allow to make change including upload something to your Google Drive account.


Need Your Help

Creating a SQL Server table from a C# datatable

c# sql-server ado.net datatable

I have a DataTable that I manually created and loaded with data using C#.

Handling dates with Asp.Net MVC and KnockoutJS

javascript asp.net asp.net-mvc json knockout.js

I recently started working with KnockoutJs and quickly realized using the default Json(myModelWithADate) resulted in the default json encoding of \/Date(-62135578800000)\/ With a bit of research I