[Google Drive Api在Google Play中发布应用程序后停止工作

问题描述 投票:0回答:1

在我的应用中,我正在使用Google Drive API,但通过Google Play安装该应用时,我收到以下消息:

  com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
    {
      "code": 403,
      "errors": [
        {
          "domain": "usageLimits",
          "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
          "reason": "dailyLimitExceededUnreg",
          "extendedHelp": "https://code.google.com/apis/console"
        }
      ],
      "message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
    }
        at d.f.b.a.b.d.a.b.newExceptionOnError(AbstractGoogleJsonClientRequest.java:2)
        at d.f.b.a.b.d.a.b.newExceptionOnError(AbstractGoogleJsonClientRequest.java:1)
        at d.f.b.a.b.d.b.a(AbstractGoogleClientRequest.java:5)
        at d.f.b.a.c.p.a(HttpRequest.java:88)
        at d.f.b.a.b.d.c.executeUnparsed(AbstractGoogleClientRequest.java:3)
        at d.f.b.a.b.d.c.executeUnparsed(AbstractGoogleClientRequest.java:1)
        at d.f.b.a.b.d.c.execute(AbstractGoogleClientRequest.java:1)

我的代码遵循Google中的示例:

final GoogleAccountCredential credential =
                GoogleAccountCredential.usingOAuth2(
                        this, Collections.singleton(DriveScopes.DRIVE_FILE));
        credential.setSelectedAccount(googleAccount.getAccount());
        final Drive googleDriveService =
                new Drive.Builder(
                        AndroidHttp.newCompatibleTransport(),
                        new GsonFactory(),
                        credential)
                        .setApplicationName(getString(R.string.app_name))
                        .build();

        mDriveServiceHelper = new DriveServiceHelper(googleDriveService);

mDriveServiceHelper.queryFiles()
                    .addOnSuccessListener(fileList -> {
                    // Logic to load the data

                    })
                    .addOnFailureListener(exception -> {
                        Log.e(TAG, "Unable to query files.", exception);
                        // This is where it fails
                    });

我能够登录用户,但是随后尝试检索文件时,失败的原因是dailyLimitExceededUnreg

我看过几个例子,例如:

我已经通过Google Play中的应用签名证书创建了OAuth令牌,并且SHA1也包含在Firebase中,我已经将其包含在项目中。我还创建了新的API密钥,该应用程序未超出每日限制。

[该应用程序在本地成功运行,我假定是由于调试证书,但不确定为什么从Google Play下载时它不起作用。

有什么建议吗?

android google-drive-api certificate sha1 google-drive-android-api
1个回答
0
投票

这可能是由于您的Android应用在Google Play上的SHA键不同。在将您的应用上传到Playstore时,您必须已启用Google应用签名,这会导致该应用在Playstore上具有不同的SHA键。您可以从Play控制台获取此SHA密钥。将此密钥添加到您的Firebase项目中,应用程序应该可以正常工作。

© www.soinside.com 2019 - 2024. All rights reserved.