未经授权与Google日历API v3进行互动 [英] Unauthorized interaction with google calendar API v3

查看:91
本文介绍了未经授权与Google日历API v3进行互动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的情况与(只是我的问题是与Python):我试图检索数据使用服务帐户(使用这个例子,然后阅读此博客条目因为我的应用程序是谷歌应用程序),但我碰到一个需要登录错误,我无法理解为什么。

I'm in the same situation as this guy (only that my problem is with python): I'm trying to retrieve data using a service account (using this example and after reading this blog entry since my application is a google app) but I get hit with a login required error and I cannot understand why.

让我用一个完整的例子来表示它:

Let me represent it with a whole example:

In [1]: import httplib2                                                          
In [2]: from apiclient.discovery import build                                   
In [3]: from oauth2client.client import SignedJwtAssertionCredentials            
In [4]: f = open('abd45679ffg32343-privatekey.p12', 'rb')
In [5]: key = f.read()                                                          
In [6]: f.close()                                                               
In [7]: credentials = SignedJwtAssertionCredentials(                            
        '2127313127654990@developer.gserviceaccount.com', key,                     
        scope=['https://www.googleapis.com/auth/calendar',                      
               'https://www.googleapis.com/auth/calendar.readonly'])            
In [8]: http = httplib2.Http()                                                  
In [9]: http = credentials.authorize(http)                                      
In [10]: service = build(serviceName='calendar', version='v3', http=http,       
   ....:         developerKey='XcddfRgtyt676grggtT')        
2012-05-14 18:24:35,170 INFO  [root][MainThread] URL being requested: https://www.googleapis.com/discovery/v1/apis/calendar/v3/rest                                                              
2012-05-14 18:24:35,170 INFO  [oauth2client.client][MainThread] Attempting refresh to obtain initial access_token
2012-05-14 18:24:35,179 INFO  [oauth2client.client][MainThread] Refresing access_token
In [11]: service.calendarList().list().execute()                                
2012-05-14 18:25:00,418 INFO  [root][MainThread] URL being requested https://www.googleapis.com/calendar/v3/users/me/calendarList?alt=json&key=XcddfRgtyt676grggtT          
---------------------------------------------------------------------------     
HttpError                                 Traceback (most recent call last)     
/home/mariano/Code/Kalendar/rest/kalendar/<ipython-input-12-0cb769615d74> in <module>()
----> 1 service.calendarList().list().execute()                                 
/home/mariano/Code/Kalendar/rest/env/local/lib/python2.7/site-packages/google_api_python_client-1.0beta8-py2.7.egg/apiclient/http.pyc in execute(self, http)                                     
387                                                                         
388       if resp.status >= 300:                                            
--> 389         raise HttpError(resp, content, self.uri)                        
390     return self.postproc(resp, content)                                 
391                                                                         
HttpError: <HttpError 403 when requesting https://www.googleapis.com/calendar/v3/users/me/calendarList?alt=json&key=XcddfRgtyt676grggtT returned "The user must be signed up for Google Calendar.">                   

任何有关为什么会发生这种情况的指针以及如何解决这个问题将不胜感激。

Any pointers about why is this happening and how to solve it would be greatly appreciate.

推荐答案

我认为服务帐户不适用于Calendar API。该服务帐户没有自己的日历。

I don't think service accounts are available for Calendar API. The service account has no calendar of its own.

这篇关于未经授权与Google日历API v3进行互动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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