如何在不使用 gdata oauth2 工作流程的情况下授权 gdata 客户端? [英] How do I authorize a gdata client without using the gdata oauth2 workflow?

查看:24
本文介绍了如何在不使用 gdata oauth2 工作流程的情况下授权 gdata 客户端?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经有一个 access_token 和 refresh_token,但我无法找到一种方法来创建授权的 gdata 客户端,而无需经过 gdata 中的整个令牌生成工作流程.

I already have an access_token and refresh_token, but I can't figure out a way to create an authorized gdata client without going through the entire token generation workflow in gdata.

推荐答案

所以我终于开始工作了.我是这样做的:

So I got this working finally. Here's how I did it:

    client = gdata.contacts.client.ContactsClient()
    credentials = gdata.gauth.OAuth2Token(client_id = 'client_id',
                                          client_secret = 'client_secret',
                                          scope = 'https://www.google.com/m8/feeds/',
                                          user_agent = auth.user_agent, # This is from the headers sent to google when getting your access token (they don't return it)
                                          access_token = auth.access_token,
                                          refresh_token = auth.refresh_token)

    credentials.authorize(client)
    contacts = client.get_contacts()

这篇关于如何在不使用 gdata oauth2 工作流程的情况下授权 gdata 客户端?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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