android - Google Api 返回 "The API (Blogger API) is not enabled for your project.",即使我在控制台中启用了 Blogger API

标签 android oauth-2.0 google-api token blogger

因此,在启用 Blogger Api 之后,我在我的控制台中为我的 Android 应用程序创建了凭据。

我通过以下方式获取我的 token :

final String SCOPE = "oauth2:https://www.googleapis.com/auth/blogger";
mToken = GoogleAuthUtil.getToken(this, email, SCOPE);

然后我将它传递给:

        HttpClient httpclient = new DefaultHttpClient();
        HttpGet httpGet = new HttpGet(
                "https://www.googleapis.com/blogger/v3/users/self");
        httpGet.addHeader("Authorization", "Bearer " + mToken);

        HttpResponse response = httpclient.execute(httpGet);
        StatusLine statusLine = response.getStatusLine();
        if (statusLine.getStatusCode() == HttpStatus.SC_OK) {
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            response.getEntity().writeTo(out);
            String responseString = out.toString();
            out.close();
            // ..more logic
        } else {
            // Closes the connection.
            response.getEntity().getContent().close();
            throw new IOException(statusLine.getReasonPhrase());
        }

不知何故,我不断得到:

{
    "error": {
        "errors": [
            {
                "domain": "usageLimits",
                "reason": "accessNotConfigured",
                "message": "Access Not Configured. The API (Blogger API) is not enabled for your project. Please use the Google Developers Console to update your configuration.",
                "extendedHelp": "https://console.developers.google.com"
            }
        ],
        "code": 403,
        "message": "Access Not Configured. The API (Blogger API) is not enabled for your project. Please use the Google Developers Console to update your configuration."
    } }

第一次使用电子邮件时确实会出现具有 Blogger 权限的同意屏幕,但在按“确定”后,什么也没有发生,我只在我的日志中看到了这一点

04-23 21:10:46.526: W/System.err(23010): java.io.IOException: Forbidden

我有预感 Google 不匹配包名称/SHA1,即使我已经正确设置了它们。

任何人都可以指出我是否错过了重要的一步/这里做错了什么?任何事情都会有所帮助:)

最佳答案

问题出在我身上。最初,我使用的 SHA-1 指纹是通过 Eclipse > 导出从 APK 中获取的。

SHA-1 google api 询问来自您的 android debug.keystore

来自 https://developers.google.com/+/quickstart/android , 得到它:

In a terminal, run the the Keytool utility to get the SHA-1 fingerprint of the certificate. For the debug.keystore, the password is android.

keytool -exportcert -alias androiddebugkey -keystore <path-to-debug-or-production-keystore> -list -v

Note: For Eclipse on Mac OS or Linux, the debug keystore is typically located at ~/.android/debug.keystore file path. On Windows, the debug keystore is typically located at %USERPROFILE%.android\debug.keystore.

关于android - Google Api 返回 "The API (Blogger API) is not enabled for your project.",即使我在控制台中启用了 Blogger API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29824799/

相关文章:

c# - C# 的快速启动示例应用程序不起作用。有想法吗?

java - 如何在完成上一个 Activity 后刷新 Activity 中的 ListView ?

java - 当我运行应用程序时,已排序的 ArrayList 未显示为已排序

oauth-2.0 - 带有授权码的刷新 token 的 OAuth2 目的

iOS:OAuth2Client 和谷歌

google-api - 获取 youtube 视频的评论 - dart

android - 安装在 Android 设备中的已发布 APK 被 Play Protect 错误阻止

android - Firebase Crashlytics 报告 InflateException : ResourceNotFoundException for a Trend TaintArt for 4x6

android - RecyclerView 不能应用于 FlexboxLayoutManager

c# - Asp.Net Core WebApi 的身份验证失败并显示 "Unprotect ticket failed"