1

Hi guys i plan at my android side to retrieve some documents file from my google drive,but always failed mention:

Drive item not found, or you are not authorized to access it.

Here is my code the problem part is the "EXISTING_FILE_ID "

private static final String EXISTING_FILE_ID = "0BxyOMAFcmxoYTkt6cHZwcUtaNlU";
private static final int REQUEST_CODE = 102;
private GoogleApiClient googleApiClient;
private static final String TAG = "retrieve_contents";

First:i tried to get my shared documents link at google drive and pick the key values example,0BxyOMAFcmxoYTkt6cHZwcUtaNlU https://drive.google.com/file/d/0BxyOMAFcmxoYTkt6cHZwcUtaNlU/view?usp=sharing

Second:i use my android side application to create a file,and retrieved a DriveId:CAESABiiHyCcwq2SpVMoAA== but still unable to retrieve file content this problem confused me Several days does some one help me ?

user2953788
  • 157
  • 3
  • 17

2 Answers2

1

From the fact that you mention 'EXISTING_FILE_ID', I assume you are referring to the demo code here.

So, to answer the point called 'First' above: The error tells you that you're trying to access a file, not created by your Android app. GDAA supports only SCOPE_FILE scope, e.g. only files created by the Android app can by found, opened, modified,...

The point called 'Second': You are (probably) correctly trying to access a file created by your Android app, but using incorrect ID. The ID I'm seeing is a 'DriveId', different from 'ResourceId' you are supposed to use (see SO 29030110 here).

The most immediate solution would be to turn your DriveId into ResourceId by means of

 DriveId driveId = DriveId.decodeFromString("DriveId:CAESABii.....");
 String EXISTING_FILE_ID = driveId.getResourceId();

And try that ID.

Good Luck

Community
  • 1
  • 1
seanpj
  • 6,735
  • 2
  • 33
  • 54
  • 1
    Consider using the picker to get access to files not created by your application, as in this sample: https://github.com/googledrive/android-demos/blob/master/src/com/google/android/gms/drive/sample/demo/PickFileWithOpenerActivity.java – Arthur Thompson May 18 '15 at 23:06
0

@user2953788 Did you solve this issue? I have the same example working and I can see 2 potential issues that could give you the error you have mentioned (you have not pasted the actual error log)

1) You have not given access to the app to Google drive (less likely since you followed tutorial) 2) The variable "public static final String EXISTING_FILE_ID" in the BaseDemoActivity.java in the sample code is not updated with the latest EXISTING_FILE_ID that you have in your Google drive. Every time you delete or add the file the ID changes even if the file name is not changed. This is more likely cause of your error. I assume you know how to find the EXISTING_FILE_ID of any file in Google drive as given in the Google tutorials.

All the best!

Ajay B
  • 746
  • 9
  • 19