无法理解如何使用Drive API

时间:2013-01-15 12:55:11

标签: java android google-drive-api

我正在尝试在我们的应用程序中实现Google云端硬盘功能并遇到此类问题:使用此代码

try {
    // File's binary content
    java.io.File fileContent = new java.io.File(Environment.getExternalStorageDirectory() + "/miniclipId.txt");
    FileContent mediaContent = new FileContent("text/plain", fileContent);

    // File's metadata.
    File body = new File();
    body.setTitle(fileContent.getName());
    body.setMimeType("text/plain");

    FileList file = service.files().list().execute();
    if (file != null) {
        //showToast("Photo uploaded: " + file.getTitle());
        //startCameraIntent();
    }
} catch (UserRecoverableAuthIOException e) {
      startActivityForResult(e.getIntent(), REQUEST_AUTHORIZATION);
} catch (IOException e) {
      showToast(e.getMessage());
}

我正在尝试将简单的文本文件发送到Google云端硬盘,运气不好,我得到了这个例外:

{
  "code": 403,
  "errors": [
    {
      "domain": "usageLimits",
      "message": "Access Not Configured",
      "reason": "accessNotConfigured"
    }
  ],
  "message": "Access Not Configured"
}

我在google API控制台中启用了Drive API,输入了SHA1调试指纹,应用的包名称与在API控制台中输入的完全相同。 有什么想法吗?

2 个答案:

答案 0 :(得分:0)

我在2个月前遇到了同样的错误。我的问题是.android文件夹有一些损坏的数据(我支持的密钥库)所以我从另一台PC中复制了该文件夹,我正在开发并解决它。 也许它有帮助...无论如何,如果你没有该文件夹的备份,我会再次创建密钥库并在API控制台中输入新的证书SHA1。 见google drive api error 403 Access Not configured

答案 1 :(得分:0)

只需注册您的应用程序或删除旧的Oauth ID并创建一个新的,并且您不会再次出现此错误: https://cloud.google.com/console#/project

https://groups.google.com/forum/#!topic/gs-discussion/9Ri4AwdHqDg