Skip to main content
 首页 » 编程设计

python + appengine + oauth2 + 谷歌联系人 api

2025年05月04日21jackei

所以我真的很困惑。主要是关于拥有一个在 python 应用程序引擎上运行的 Web 应用程序的“正确”方式,该应用程序可以与用户交谈以让他们通过 oauth2 权限接受,以便我的应用程序引擎应用程序可以读取/写入他们的联系人数据库。我有一些类似的东西(基于 http://code.google.com/p/google-api-python-client/ 上的应用引擎示例,特别是 http://code.google.com/p/google-api-python-client/source/browse/#hg%2Fsamples%2Fappengine )

我已将 SCOPES 修改为

SCOPES = ( 
          'https://www.google.com/m8/feeds','https://www.googleapis.com/auth/plus.me' 
          ) 

但我得到的问题是我不想运行

        http = decorator.http() 
        user = service.people().get(userId='me').execute(http=http) 

但是像

        http = decorator.http() 
        user = service.contacts().get(userId='*').execute(http=http) 

然而,对于我的生活,我不知道在服务之后放什么......功能......当然我不知道如何用谷歌搜索它......好吧我不知道我用什么术语我在谷歌上搜索。

我试过修改服务构造函数..但我还是不知道要在里面放什么。

service = build("plus", "v1", http=http)  ### works for g+ 
contact_service = build("m8","v3",http=http) ### doesn't work for toffee 

我确实在这里看到了这项工作:Retrieving contacts with gdata.contacts.client and oauth2但宁愿使用“stock google”解决方案,因为他们倾向于维护那些 ..(通常)

好吧.. 仔细研究后我发现了这个有用的 meta-api 调用:

https://www.googleapis.com/discovery/v1/apis/

其中完全没有提及联系 api。我是否认为这种方法不合适?

请您参考如下方法:

当前版本的联系人 API (v3) 使用较旧的 gdata-python-client library ,不是新的 google-api-python-client .有关将 OAuth 2.0 与 gdata Python API 一起使用的详细信息,请参阅此 blog entry .博客调用日历和文档客户端 API,但联系人应该非常相似。