google plus api:“权限不足";错误 [英] google plus api: "insufficientPermissions" error

查看:27
本文介绍了google plus api:“权限不足";错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用 api 搜索 google plus

I am searching the google plus with api

这是我的网址:https://www.googleapis.com/plus/v1/activities?query=internet%20marketing&access_token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

这里是回复:

{
   "error": {
     "errors": [
      {
         "domain": "global",
         "reason": "insufficientPermissions",
         "message": "Insufficient Permission"
      }
     ],
   "code": 403,
   "message": "Insufficient Permission"
   }
}

这是我的 API 控制台屏幕 http://i.stack.imgur.com/jO27J.png

Here is my API CONSOLE screen http://i.stack.imgur.com/jO27J.png

谁能告诉我需要在 api 控制台中为我的应用程序设置什么权限.?

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.

如果您在检索访问令牌时未请求所需的范围,则会返回权限不足错误.猜测一下,由于您使用的是 Google+ API 和 YouTube API,您可能只请求了 YouTube 范围,而不是两者,即:

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:

检查您是否同时要求:

https://www.googleapis.com/auth/youtube
https://www.googleapis.com/auth/plus.login

而不仅仅是第一个.

您可以通过将您的 access_token 传递给此端点来检查您请求的范围:

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.

顺便说一下,https://www.googleapis.com/plus/v1/activities?query=QUERY 是未经身份验证的调用,因此您可以传递项目的 API 密钥而不是访问令牌.如果您使用 https://www.googleapis.com/plus/拨打电话v1/activities?query=QUERY&key=API-KEY,那么您根本不需要请求范围或获取访问令牌.

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.

如果您还没有看过它,您可以在 OAuth 2.0 Playground 尝试您想进行的 API 调用:

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:“权限不足";错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆