0

i am building an android app using google drive api.First i get resourceId of a folder ("shared with me with edit access") using files:list rest api.i get Folder

Id="0B6DwkfjCNXHYflJVOGdnbFU0QkxfU25NbHV5UjNfVmNlNWhhcllnbktmNDNReEhuMm83X0E"

public class MainActivity extends BaseDemoActivity {


    @Override
    public void onConnected(Bundle connectionHint) {
        super.onConnected(connectionHint);

        Drive.DriveApi.fetchDriveId(getGoogleApiClient(),"0B6DwkfjCNXHYflJVOGdnbFU0QkxfU25NbHV5UjNfVmNlNWhhcllnbktmNDNReEhuMm83X0E")
        .setResultCallback(idCallback);


    }

    final private ResultCallback<DriveIdResult> idCallback = new ResultCallback<DriveIdResult>() {
        @Override
        public void onResult(DriveIdResult result) {
            if (!result.getStatus().isSuccess()) {
                showMessage("Cannot find DriveId. Are you authorized to view this file?");
                return;
            }
            Log.i("driveId is: ", result.toString());
            showMessage("Drive Id is: "+result.toString());
            DriveId driveId = result.getDriveId();
            Log.i("drive Id is",driveId.toString());

            //showMessage("Drive Id is: " + driveId.toString());
           /*  DriveFile ff =  driveId.asDriveFile();
            ff.getMetadata(getGoogleApiClient()).setResultCallback(metadataRetrievedCallback);
*/
           /* DriveFolder folder = driveId.asDriveFolder();
            Query query = new Query.Builder()
                    .addFilter(Filters.eq(SearchableField.MIME_TYPE, "text/plain"))
                    .build();
            folder.queryChildren(getGoogleApiClient(), query)
                    .setResultCallback(metadataCallback);*/
        }
    };
    ResultCallback<DriveResource.MetadataResult> metadataRetrievedCallback = new
            ResultCallback<DriveResource.MetadataResult>() {
                @Override
                public void onResult(DriveResource.MetadataResult result) {
                    if (!result.getStatus().isSuccess()) {
                        showMessage("Problem while trying to fetch metadata");
                        return;
                    }
                    Metadata metadata = result.getMetadata();
                    showMessage("Metadata succesfully fetched. Title: " + metadata.getTitle());
                }
            };
}

i set up the project as described in google drive android api.but when i run my code i am getting in callback error "Cannot find DriveId. Are you authorized to view this file?"

Anirudh Sharma
  • 7,968
  • 13
  • 40
  • 42
mathlearner
  • 7,509
  • 31
  • 126
  • 189
  • I think it is because of the Id you are using. It should be the resourceId instead of the driveId. See this [link](http://stackoverflow.com/questions/28690401/cannot-find-driveid-are-you-authorized-to-view-this-file-even-if-existing-f). You should use `....getDriveId().getResourceId()` instead of just `....getDriveId()`. – gerardnimo Jan 31 '16 at 10:50
  • No I am using ResourceId. – mathlearner Feb 01 '16 at 03:27
  • Any solution on this ? – flaviussn Oct 16 '17 at 15:57

0 Answers0