Google Api returns "The API (Blogger API) is not enabled for your project." 即使我在控制台中启用了 Blogger API
Google Api returns "The API (Blogger API) is not enabled for your project." even though I've enabled Blogger API in console
所以在启用 Blogger Api 之后,我在我的控制台中为我的 Android 应用程序创建了凭据。
我通过以下方式获取我的令牌:
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 权限的同意屏幕,但在按下 "OK" 后,没有任何反应,我只在我的日志中看到这个
04-23 21:10:46.526: W/System.err(23010): java.io.IOException:
Forbidden
我有预感 Google 与包 names/SHA1 不匹配,即使我已经正确设置了它们。
任何人都可以指出我是否错过了重要的 step/did 这里有什么问题吗?任何事情都会有所帮助:)
问题出在我身上。最初,我使用的 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.
所以在启用 Blogger Api 之后,我在我的控制台中为我的 Android 应用程序创建了凭据。
我通过以下方式获取我的令牌:
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 权限的同意屏幕,但在按下 "OK" 后,没有任何反应,我只在我的日志中看到这个
04-23 21:10:46.526: W/System.err(23010): java.io.IOException: Forbidden
我有预感 Google 与包 names/SHA1 不匹配,即使我已经正确设置了它们。
任何人都可以指出我是否错过了重要的 step/did 这里有什么问题吗?任何事情都会有所帮助:)
问题出在我身上。最初,我使用的 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.