google plus api:“insufficientPermissions”错误 [英] google plus api: "insufficientPermissions" error
问题描述
我正在用api搜索google plus。
这里是回应:
{
错误:{
errors:[
{
domain:global,
reason:insufficientPermissions,
message: 权限不足
}
],
code:403,
message:权限不足
}
}
以下是我的API CONSOLE屏幕 http://i.stack.imgur.com/jO27J.png
任何人都可以告诉我需要什么许可在api控制台中设置我的应用程序。 ?
这是您的访问令牌问题,而不是您的项目配置。 b $ b
当您检索访问令牌时,如果尚未请求所需的范围,则会返回权限不足错误。有人猜测,由于您使用的是Google+ API和YouTube API,因此您可能只需要申请YouTube范围,但不能同时申请,即: b
$ b
:
https://www.googleapis.com/auth/youtube
https://www.googleapis。 com / auth / plus.login
而不仅仅是第一个。
您可以通过将access_token传递到此端点来检查您请求的范围: googleapis.com/oauth2/v1/tokeninfo?access_token=ACCESS_TOKEN\">https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=ACCESS_TOKEN
我无法检查示例中的令牌,因为它已过期(访问令牌在一小时后过期)。此外,请勿公开访问令牌,因为他们允许他人访问您的数据 - 他们应该保密并小心处理。
顺便说一句,https://www.googleapis.com/plus/v1/activities?query=QUERY 是未经验证的电话,所以您可以将您的API密钥传递给您的项目,而不是访问令牌。如果您通过 https://www.googleapis.com/plus/致电v1 / activities?query = QUERY& key = API-KEY ,那么您就不需要请求范围或获取访问令牌。
如果您还没有看到它,可以尝试一下您希望在OAuth 2.0 Playground上进行的API调用:
https://developers.google.com/oauthplayground/
这是查看效果的好地方什么不是。
I am searching the google plus with api
Here is my Url: https://www.googleapis.com/plus/v1/activities?query=internet%20marketing&access_token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
here is response:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "insufficientPermissions",
"message": "Insufficient Permission"
}
],
"code": 403,
"message": "Insufficient Permission"
}
}
Here is my API CONSOLE screen http://i.stack.imgur.com/jO27J.png
Can Anyone tell what permission I need to setup for my app in api console. ?
This is a problem with your access token, not with your project configuration.
The insufficient permissions error is returned when you have not requested the scopes you need when you retrieved your access token. At a guess, since you are using the Google+ API and the YouTube API, you may have only requested the YouTube scope and not both, ie:
Check you have requested both:
https://www.googleapis.com/auth/youtube
https://www.googleapis.com/auth/plus.login
and not just the first one.
You can check which scopes you have requested by passing your access_token to this endpoint:
https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=ACCESS_TOKEN
I can't check the token in your example because it has expired (access tokens expire after one hour). Also, please do not post access tokens publicly as they allow others access to your data - they should be kept secret and treated with care.
Incidentally, https://www.googleapis.com/plus/v1/activities?query=QUERY is an unauthenticated call, so you could pass your API key for your project rather than an access token. If you make the call with https://www.googleapis.com/plus/v1/activities?query=QUERY&key=API-KEY, then you wouldn't need to request scopes or fetch an access token at all.
If you haven't seen it already, you can try out the API calls you would like to make at the OAuth 2.0 Playground:
https://developers.google.com/oauthplayground/
That's a good place to see what works and what doesn't.
这篇关于google plus api:“insufficientPermissions”错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!