Python oauth2 - getting access token

前提是你 提交于 2019-12-24 07:14:24

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/11100216/python-oauth2-getting-access-token

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!