Android 谷歌人物形象+&引用;“拒绝许可”;错误
我试图使用Google+提供的PersonAPI获取性别和出生日期,但我在日志中收到服务器端错误 这是我的日志:Android 谷歌人物形象+&引用;“拒绝许可”;错误,android,google-plus,Android,Google Plus,我试图使用Google+提供的PersonAPI获取性别和出生日期,但我在日志中收到服务器端错误 这是我的日志: com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden { "code" : 403, "errors" : [ { "domain" : "global", "message" : "Request had insufficient authentication scopes.
com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
"code" : 403,
"errors" : [ {
"domain" : "global",
"message" : "Request had insufficient authentication scopes.",
"reason" : "forbidden"
} ],
"message" : "Request had insufficient authentication scopes.",
"status" : "PERMISSION_DENIED"
}
我正在使用以下代码:
ListConnectionsResponse response = peopleService.people().connections()
.list("people/me")
.execute();
请告诉我我错过了什么?非常感谢您的帮助。您必须在发送任何Google API请求之前进行授权。 就是 和捕获成功回调:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case RC_INTENT:
Log.d(TAG, "sign in result");
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()) {
GoogleSignInAccount acct = result.getSignInAccount();
Log.d(TAG, "onActivityResult:GET_TOKEN:success:" + result.getStatus().isSuccess());
// This is what we need to exchange with the server.
Log.d(TAG, "auth Code:" + acct.getServerAuthCode());
// PUT YOUR WANTED CODE HERE
} else {
Log.d(TAG, result.getStatus().toString() + "\nmsg: " + result.getStatus().getStatusMessage());
}
break;
}
}
但是我没有手动检索任何访问令牌。我所做的就是获取PeopleService对象并对其启动“people/me”rest调用。你实现了这个代码吗?还有这个:?
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case RC_INTENT:
Log.d(TAG, "sign in result");
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()) {
GoogleSignInAccount acct = result.getSignInAccount();
Log.d(TAG, "onActivityResult:GET_TOKEN:success:" + result.getStatus().isSuccess());
// This is what we need to exchange with the server.
Log.d(TAG, "auth Code:" + acct.getServerAuthCode());
// PUT YOUR WANTED CODE HERE
} else {
Log.d(TAG, result.getStatus().toString() + "\nmsg: " + result.getStatus().getStatusMessage());
}
break;
}
}