因此,在启用Blogger Api后,我在我的控制台中为我的Android App创建了凭据。
我通过以下方式获取令牌:
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 permisison的同意屏幕确实显示,但在按“确定”后,没有任何反应,我只在日志中显示
04-23 21:10:46.526:W / System.err(23010):java.io.IOException: 禁
即使我已经正确设置了Google,但我还是预感到Google与软件包名称/ SHA1不匹配。
任何人都可以指出我是否错过了一个重要步骤/在这里做错了什么?任何事都会有所帮助:)
答案 0 :(得分:1)
问题出在我身上。最初,我使用的SHA-1指纹是通过Eclipse>从APK中获取的。出口。
SHA-1 google api问你是来自你的android debug.keystore
从https://developers.google.com/+/quickstart/android获取它:
在终端中,运行Keytool实用程序以获取SHA-1 证书的指纹。对于debug.keystore,密码 是android。
keytool -exportcert -alias androiddebugkey -keystore <path-to-debug-or-production-keystore> -list -v
注意:对于Mac OS或Linux上的Eclipse,通常使用调试密钥库 位于〜/ .android / debug.keystore文件路径。在Windows上,调试 密钥库通常位于 %USERPROFILE%.android \ debug.keystore。