google-drive-sdk,google-drive-android-api , User disconnecting app in Drive causes loss of data under FILE scope

User disconnecting app in Drive causes loss of data under FILE scope


Tag: google-drive-sdk,google-drive-android-api

I've run into this issue a few times, but could never point my finger on it, attributing it to GDAA's latency, my buggy code, etc... I finally managed to come up with a scenario where I can safely reproduce it, so I would like to ask people who know if it is a feature I don' understand or a plain bug. If latter is the case, please point me to the place where I can nag about it.

I will discuss it on the REST API's background for simplicity.

1/ Let's have a Drive API authenticated app that runs under DRIVE_FILE scope svc = 
  new Drive.Builder(
    new GsonFactory(),
    .usingOAuth2( context, Collections.singletonList(DriveScopes.DRIVE_FILE))

2/ create a file (files/folders) in Google drive using

svc.files().insert([METADATA], [CONTENT]).execute();

3/ search for the objects you've created using


When the app is run, user goes through the usual Account-Pick / Drive-Authorize routine and everything works as expected. Files are created, visible, can be found ... until a user revokes the authorization by means of

Settings > Manage Apps > Disconnect From Drive


After that, if the Android app is restarted (and re-authorized), none of the objects created prior the revocation is visible.

It may be by design, I don't know. If this is the case, I can't find a way how the Android app can get to anything it created before. I could certainly create another 'maintenance' app with DRIVE scope to fix this, but...

Now, in case of GDAA, it gets even worse. Not only GDAA does not have the DRIVE scope to fix it, but if the same sequence of steps is done and the app creates a file/folder immediately after revocation, GDAA does not complain, but the file/folder is not created at all. After a while (minutes), the re-authorization pops-up, but still, the files created meanwhile are nowhere to be found and everything pre-dating the revocation is lost to the (creator) app as well (it certainly is visible in the web app that obviously has DRIVE like scope).

Thank you for you patience.


The first issue is:

  1. A user revokes authorization via: Settings > Manage Apps > Disconnect From Drive
  2. Then reauthorizes that App
  3. Files this App was authorized to see with DRIVE_FILE scope are no longer authorized.

This is the expected behavior of the REST and Android APIs.

We don't think users would intuitively expect all previously authorized files to be re-authorized. The user may not remember the files that were previously authorized, and informing users that these files are going to be authorized again will likely cause confusion.

The second issue is GDAA's behavior for folder creation in this situation. We don't currently support CompletionEvents for folder creations, but this is something we'll look into.


Advanced Drive Services in Addons

I have a Google Script that uses the Advanced Drive API service and am now looking to convert this script into an Add-on. However the Drive API needs to be enabled manually by the user before using the service inside the Apps Script. Is it possible to use the advanced...

Removing permissions of the extensions

I have an extension that first asks for permissions to access Google Drive files. The extension is almost empty except in the popup I load this js: chrome.identity.getAuthToken({ 'interactive': true }, function(token) { // Use the token. console.log('Request Token') console.log(token) chrome.identity.removeCachedAuthToken( { 'token': token }, function () {}) console.log('Removed token')...

google-apps-script count files in folder

I've had a search but cannot seem to find what I am looking for. I am seeking the code to enable me to do this pseudocode: Count number of files in specific Google Drive folder (by folder Id) If file count is above 'x' do this {other piece of code}...

How to create a Google form programatically with python ?Is it possible to do so by appscript and python interfacing or something like that?

How to create a Google form programatically with python ? Do they provide some api like drive api to do so ? Is it possible to interface python with Google appscript ? Here they are talking about creating a form with a form using app script . Thank you...

access drive with access token

struggling to understand the oauth2 token and refresh token processes ive got this code $url = ''; $data = array('client_id' => 'clientid', 'client_secret' => 'secret','refresh_token' => 'token','grant_type' => 'refresh_token'); $options = array( 'http' => array( 'header' => "Content-type: application/x-www-form-urlencoded", 'method' => 'POST', 'approval_prompt'=>'force', 'access_type'=>'offline', 'content' => http_build_query($data), ), ); $context...

Google Drive file download via http

There is a link to Google Drive file accessible to anyone without authentication. Is there any way to download that file using just link and some sort of http client? Most of examples around are relying on Drive API and file IDs, however I'd like to stick with more lightweight...

Dynamically Create Folders and Subfolders

I have several scripts in php to create a folder and upload a file to the desired folder, but I can't seem to be able to create new folders, new subfolders or create another function to do this process. Do i have to use a parent/children specific procedure? Here's the...

Google Drive PHP Client render PDF?

I'm trying to render a PDF from a service account (the file is shared with the service). $pdf = $drive->files->get($file_id); $pdf->downloadUrl However, the resource is coming in with 401 Unauthorized. It's funny that I'm authorized to get the files and everything, but downloading the actual files is unauthorized? I want...

Google Drive API: I have to fetch only files in that folder without trashed files

I am trying to get a list of files in a folder on Google drive using the Google drive API. When I make my request I am getting a list of child elements in that folder including previous deleted files. How do I get only the files that are in...

User disconnecting app in Drive causes loss of data under FILE scope

I've run into this issue a few times, but could never point my finger on it, attributing it to GDAA's latency, my buggy code, etc... I finally managed to come up with a scenario where I can safely reproduce it, so I would like to ask people who know if...

Adding google api client to codeigniter

I want to upload files to google drive using php in codeigniter. First of all i am trying to integrate google api client to codiginator. I have uploaded all the files in to my third_party folder. it look like this I i have created a file called google.php inside my...

Any way te read an excel file from a Google Sheet?

in my organization we work with Google Apps but we have one file that we need to maintain in Excel due to its complexity. All my other spreadsheets are Google Sheets and a lot of them need to get data from that excel file. So my question is: is there...

Google Drive API every time asking for authentication code

I'm using google drive api to upload a file to google drive using php, but it every time asking me for authentication code fof my application. I have followed the steps given in the URL below My Code: require_once 'src/Google/autoload.php'; $client = new Google_Client(); // Get your credentials from...

files.get and .getRequestFactory cannot be resolved

I'm trying to get the metadata of a file in my Google Drive through the fileID but I'm running into some problems using files().get and getRequestFactory(). Specifically I'm looking at this and on the sample it shows the line File file = service.files().get(fileID).execute(); and HttpResponse resp = service.getRequestFactory().buildGetRequest(new GenericUrl(file.getDownloadUrl())).execute(); I...

Google Service account user interfece

How can I login to a Google Service account with the normal web user interface, for example to google drive ? Now I can only login using API using script....

Google Drive revokes my token

I am new to google drive and started with the tutorial quickstart. After numerous attampts I run the program successfully. However I had permission and authorisation problems when I was trying to delete files. Drive service = getDriveService(); service.files().delete("FileId").execute(); So I decide to change the URL in the client_secret.json, From:...

How to download text file from google drive using the url by the google drive api for android [closed]

I have uploaded a text file to my google drive account and it is public. I got the link for that file by the share link. What I want to do is to download that file from the drive using drive API by using the link that I obtained. And...

Is there a way to add watermark to all videos in Google Drive’s folder?

Is there a way to add watermark to all videos in Google Drive’s folder? I found similar service, but it works only with pictures, pdfs - Wappwolf Maybe, it's possible to do by Google Apps Script or some other services (like ffmpeg)?...

What is permissionId in Google API?

I am trying to replicate the JavaScript client library example shown on There is a reference to permissionId. How do I get this, I've looked everywhere, and my assumption is I am missing something dead obvious. Thanks in advance....

Google Drive list method doesn't list files created recently

I've developed an extension for Google Chrome that HEAVILY relies on Google Drive API (the extension is LBTimer, available in Google Chrome web store), to store data in the appfolder, using XMLHttpRequests Since May, 13th 2015 I'm finding a problem when using the list method. If I programmatically create a...

Can I associate a user's account with an action to the drive API?

We're looking to make a little webapp to manage our week-long nerf war (humans vs zombies to be precise), and we're thinking about how easy it would be to have Google Sheets be our only backend, and our frontend be entirely javascript/html/css. Let's say there's two actions that can be...

make a data file of google drive account using google drive api

I'am want to get all of my data in google drive into file (xml or json it's not so matter). the regular way to do it is like this: Drive service = new Drive(somedata); String fileName = service.get(fileId).execute().getTitle(); to get the file id, it's needed to do this: Children.List request...

Insert file using Google Drive API?

Based on Google Drive API reference guiding how to insert file Files.insert // File's metadata. File body = new File(); body.setTitle(title); body.setDescription(description); body.setMimeType(mimeType); // File's content. fileContent = new; FileContent mediaContent = new FileContent(mimeType, fileContent); try { File file = service.files().insert(body, mediaContent).execute(); // Uncomment the following line to...

Newbie Google Drive API (PHP) confusion - what guide/library to use?

I have a mobile site - from a phone I want visitors to choose a file from Google Drive, and send it to the server that hosts Essentially emulating a simple <input type="file"> file upload as on a desktop. From what I understand the workflow is as follows:...

Directory sandboxed access for Google Drive / Dropbox API / RemoteStorage apps?

Is there a way to get sandboxed, user-selected directory access on any major file service without first getting read level access to their entire filesystem? There's a lot of talk about "unhosted" static webapps that allow users to access their data from a 3rd party file service (Google Drive, Dropbox,...

No item with Given ID can be found

I am having issues when running my script after the most recent API update. I had some issues that I was able to fix with some help from around here but now I am having a get by ID issue. I am unsure of where it is coming from because...

Upload text file to Google Drive using Android

Edited: I have set my text into a string like so: String text = ("Hello!"); I want to turn this into a plain text file and then upload to a Google Drive Folder. I have tried on the code below, but it is not complete so I cannot say what...

Cannot get Google Drive App Data folder content using query anymore

For some reason the following Android app code drive; ... drive.files().list().setQ("mimeType='application/' and 'appdata' in parents").execute().getItems(); started returning empty list since May 14. This code was returning my custom folders for more than 1 year before. I can see my App Data content still exists through > Settings >...

The lightest (most lightweight) Google Drive REST API query/response?

When initializing the REST Google Drive API in an Android app, I need to 'poke' the server to produce the UserRecoverableAuthIOException In order to minimize the network traffic, I'm searching for the most 'lightweight' request that would produce such an exception. Currently, I use the following construct: svc; svc.files().get("root").setFields("title").execute();...

Dependency ignored because of conflict Android studio

I'm trying to add the following dependency but it is ignore. I can't understand how to resolve it please help me Thank you. Dependency compile '' Waring for ignoring dependency Warning:Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for debug as it may be conflicting with the internal version provided by Android. In case...

Google Apps Script - Add file from Google Drive

First of all I want you to know that I'm not talking about uploading a file from users computer drive. What Im aiming to do is to be able to allow users to add a file from their Google Drive to a specific folder in my Google Drive. I've searched...

Google Drive - How to List all Files in a specified folder

Hi I am stuck here with this situation, I have tried a number of different approaches but I cannot get what I am after. Situation: I have a large number of files in folders hosted on google drive. For instance a single client folder for reports has between 2000-10000 files(this...

How can I make a copy of a file in Google Drive via Python?

I wrote a short function in Google Apps script that can make a copy of a specific file that is stored on Google Drive. The purpose of it is that this file is a template and every time I want to create a new document for work I make a...

How to save my data in a cloud?

I don't know if this is possible, but I would like to save some data of my website, like images and documents in a cloud like dropbox or google drive and I want that these data are available and visible to someone looking my site. is it possible? (My intention...

Google Drive API VB.NET Parent Folder of a Folder,google-drive-sdk,folder,parent
I am trying to work with Google Drive API with I have seen a lot of post but I am not able to understand how to choose the right folder to add a file. I have a lot of "Backup" folder but, I assume now, I want to add...

Unable to get custom property via Android Drive API

Create a file and query file with custom property work fine, but it cannot retrieve custom property in queryChildren() ResultCallback. Here is the CustomProperty definition: /** * CustomPropertyKey: Uploaded file's hash code */ public static final CustomPropertyKey CustomPropertyKeyFileHash = new CustomPropertyKey("fileHash", CustomPropertyKey.PUBLIC); query conditions: Query query = new Query.Builder() .addFilter(...

Pass Comments & Suggested Edits from a Google Document to a Google Sheet

Fellow Stackers. I'm using a Google Apps Script to (a) capture all "Comments" in a Google Document... ...and (b) list them in a column of a Google Sheet... However, I'm wondering if it's possible to... (1) Array "Comments" into individual cells down a column in my Sheet rather than into...

Raised Gogle Drive API Per-user limit, still getting userRateLimitExceeded errors

Similar to Raising Google Drive API per-user limit does not prevent rate limit exceptions In Drive API Console, quotas looks like this: Despite Per-user limit being set to an unnecessarily high requests/sec, I am still getting rate errors at the user-level. What I'm doing: I am using approx 8 threads...

How to exclude trashed files when listing files in google drive

I want to list all the files in google drive using google drive api v2 . But I want to exclude files in trash in the list So I tried GET as suggested in the api documentation But still I get files in the trash folder ,Am I missing...

How do I turn off email notifications when transferring ownership?

I am setting up an api and need to change the ownership of some files in my drive from my service account to my non-service account. How do I turn off the email notifications? I've tried via both Python as well as via the docs (at the bottom of the...

Handling of Thumbnails in Google Drive Android API (GDAA)

I've run into the following problem when porting an app from REST API to GDAA. The app needs to download some of (thousands of) JPEG images based on user selection. The way this is solved in the app is by downloading a thumbnail version first, using this construct of the...

How to browse files from projects google drive

i have created project in google console with service type credentials. I have downloaded p12 key file, and then wrote sample code for inserting file to test it: <?php require_once 'google-api-php-client/src/Google_Client.php'; require_once 'google-api-php-client/src/contrib/Google_DriveService.php'; require_once "google-api-php-client/src/contrib/Google_Oauth2Service.php"; $scopes = array(''); $accountEmail = 'SECRET'; $accountP12FilePath = './key.p12'; $key = file_get_contents($accountP12FilePath);...

Is there any way to set the initial count record number for google drive files just like setMaxResults?

service.files().list().setMaxResults(50) Just like the above one is there any way to set the initial count or is it possible through query?...

Google Drive API (GTL) - Create multiple folder paths in order?

I'm using the Google APIs Client Library for Objective-C (GTL) to access the Google Drive API. According to it's Introduction to the Google APIs Client Library for Objective-C, Query execution by the service is inherently asynchronous. Which means when you try to create a path like: root/a/b/c, before you can...

401 Unauthorized - Google Drive API,.net,,google-drive-sdk
I'm working with the Google APIs for the first time and I'm having problems trying to download files with the File object "downloadUrl" property. I'm currently using the "Service Account" option with the associated service account email and P12 certificate. However, the URL returned "" returns a 401 - Unauthorized...

Google Drive API 500 null errors when copying

I'm getting this error message (100% of the time) when copying a shared file, using the latest version of php library. And I'm getting the same response via the API explorer: Google_Exception: Error calling POST (500) { "error": { "code": 500, "message": null } } This issue seem...

Can one track the usage of a shared resource from google drive

Does anyone here know if you on Google Drive somehow can track if a public shared link to a file have been used? That is, the resource have been downloaded, viewed or otherwise "touched"?...