Google Drive Android Api授权错误

时间:2016-01-31 07:37:36

标签: android google-drive-api google-drive-android-api

我正在使用谷歌驱动器api构建一个Android应用程序。首先我使用文件获取文件夹的resourceId(“与我共享编辑访问权限”):list rest api.i get Folder

  

编号= “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());
                }
            };
}

我设置了google drive android api中描述的项目。但是当我运行我的代码时,我收到回调错误“无法找到DriveId。你有权查看此文件吗?”

0 个答案:

没有答案