Android Google Drive API 异常:403 Forbidden

问题描述:

我正在开发一个可以访问用户在 Google Drive 上的 appdata 文件夹的应用.当我处于调试模式时,该应用程序运行良好.当我发布应用程序并尝试连接到 Google 云端硬盘时,它在我选择要连接的帐户后出现此错误:

I'm developing an app that has access to user's appdata folder on Google Drive. When I am on debug mode, the app works fine. When I make a release of the app and I try to connect to Google Drive it give me this error after I choose which account to connect:

com.google.api.client.googleapis.json.GoogleJsonResponseException: 
403 Forbidden 
{
   "errors" : [ {
      "domain" : "global",
      "reason" : "insufficientScopes",
      "message" : "The granted scopes do not give access to all of the requested spaces.",
      "locationType" : "parameter",
      "location" : "spaces"
   } ],
      "code" : 403,
      "message" : "The granted scopes do not give access to all of the requested spaces."
}

我使用这种方式连接到 Google Drive:https://developers.google.com/drive/v3/web/quickstart/android

I used this way to connect to Google Drive: https://developers.google.com/drive/v3/web/quickstart/android

我还在 Google Dev Console 中制作了一份用于调试的凭证和一份用于发布模式的凭证.

I also make one credential for debug and one for release mode in Google Dev Console.

我该如何解决这个问题?任何帮助都值得赞赏.谢谢小伙伴!

How can I solve this problem? Any help is apreciate. Thanks buddies!

我遇到了同样的问题,官方 ProGuard 配置在这里为我解决了:

I had the same problem and the official ProGuard configuration here solved it for me:

https://github.com/google/google-api-java-client/blob/57fe35766cbba0a0d5a9a296be81468d730a29f8/google-api-client-assembly/proguard-google-api-client.txt