Python oauth2 - 获取访问令牌 [英] Python oauth2 - getting access token

查看:40
本文介绍了Python oauth2 - 获取访问令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的 Web 应用程序中集成经过身份验证的 vimeo 用户的视频.我有这个代码 https://gist.github.com/2944212

我拨打了授权电话,现在我收到了oauth_token、oauth_token_secret、oauth_verifier.我将所有这些内容添加到参数并向以下网址发出请求,但现在出现此错误

<预><代码>>>>url = 'http://vimeo.com/oauth/access_token'>>>req = oauth.Request(method='GET', url=url, parameters=params)>>>req.sign_request(signature_method,消费者,令牌)回溯(最近一次调用最后一次):文件<console>",第 1 行,在 <module> 中文件/usr/lib/python2.7/dist-packages/oauth2/__init__.py",第502行,在sign_request中self['oauth_signature'] = signature_method.sign(self, consumer, token)文件/usr/lib/python2.7/dist-packages/oauth2/__init__.py",第838行,有符号密钥,原始 = self.signing_base(请求,消费者,令牌)文件/usr/lib/python2.7/dist-packages/oauth2/__init__.py",第832行,在signing_base键 += 转义(token.secret)AttributeError: 'str' 对象没有属性 'secret'

使用它我如何获取 access_token 并使此方法起作用 https://developer.vimeo.com/apis/advanced/methods/vimeo.videos.getUploaded

我是 oauth 的新手,我需要你的帮助.

谢谢!

更新

现在我解决了那个错误.我唯一需要的是获取访问令牌和脚本来请求此方法 https://developer.vimeo.com/apis/advanced/methods/vimeo.videos.getUploaded

解决方案

如果我理解正确,您现在拥有访问令牌了吗?

要向 API 端点发出请求,请遵循相同的过程,但使用访问令牌(作为 oauth_token 参数)和 req.sign 方法.当然,也将您的请求指向 API URL :)

一旦您拥有访问令牌,您就不需要 oauth_verifier.

I want to integrate authenticated vimeo user's videos in my web application. I have this code https://gist.github.com/2944212

I made authorize call and now I got oauth_token, oauth_token_secret, oauth_verifier. I added all these things to the parameter and made request to the below url, but now I'm getting this error

>>> url = 'http://vimeo.com/oauth/access_token'
>>> req = oauth.Request(method='GET', url=url, parameters=params)
>>> req.sign_request(signature_method, consumer, token)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/oauth2/__init__.py", line 502, in sign_request
self['oauth_signature'] = signature_method.sign(self, consumer, token)
File "/usr/lib/python2.7/dist-packages/oauth2/__init__.py", line 838, in sign
key, raw = self.signing_base(request, consumer, token)
File "/usr/lib/python2.7/dist-packages/oauth2/__init__.py", line 832, in signing_base
key += escape(token.secret)
AttributeError: 'str' object has no attribute 'secret'

Using that how can I fetch access_token and make this method to work https://developer.vimeo.com/apis/advanced/methods/vimeo.videos.getUploaded

I'm new to oauth and I need your help.

Thanks!

UPDATE

Now I solved that error. The only thing I need is to get the access token and a script to make the request for this method https://developer.vimeo.com/apis/advanced/methods/vimeo.videos.getUploaded

解决方案

If I understand correctly you now have the access token?

To make requests to the API endpoint follow the same procedure but use the access token (as the oauth_token parameter) and in the req.sign method. Direct your request towards the API URL aswell, of course :)

And you don't need the oauth_verifier once you have the access token.

这篇关于Python oauth2 - 获取访问令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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