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

查看:84
本文介绍了如何在不使用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天全站免登陆