1

我试图授权我的应用程序使用谷歌加。但是,当我使用人员服务并试图获得“我”时,除了使用创建Google+ API应用的用户登录时,我尝试过的所有内容总是会给我一个404。这对我的原因没有任何意义。无法使用谷歌加API进行授权

from httplib2 import Http 
from apiclient.discovery import build 
credential = gp_client.step2_exchange(request.REQUEST) 
http = Http() 
http = credential.authorize(http) 
service = build("plus", "v1", http=http) 
o = service.people().get(userId='me').execute() 

同样也是如此,当我使用Google+探险:

http://code.google.com/apis/explorer/#_s=plus&_v=v1&_m=people.get&fields=emails

如果我切换到私人与谁创造了API,那么我可以取“我”的用户,但如果我授权另一个用户,那么我无法获取'我'。

任何想法发生了什么?

+0

显示您在哪里定义'gp_client' – Daenyth 2012-02-02 21:44:55

回答

1

终于搞清楚这是什么。 Google允许您授权任何应用的Google帐户。但是,如果授权用户未升级到Google+,那么当应用发出其第一个Google+ API请求时,请求将会是404。这是令人难以置信的,因为当我设置OAuth2WebServerFlow时,我指定了“plus.me”作为范围。恕我直言,Google应该在用户尝试授权此OAuth请求时通知用户升级到Google+。

gp_client = OAuth2WebServerFlow(
    settings.GOOGLE_PLUS_CONSUMER_ID, 
    settings.GOOGLE_PLUS_CONSUMER_SECRET, 
    scope='https://www.googleapis.com/auth/plus.me', 
)