Python oauth2 - 发出请求 [英] Python oauth2 - making request
问题描述
我想将用户的 vimeo 视频集成到我的 Web 应用程序中,并且我在 github 中获得了此代码 https://gist.github.com/2944212 使用该代码我可以获取 oauth_signature 值.
现在我有了这个参数.
params = {'oauth_consumer_key': 'XXXXXXXXXXXXXXXXXXXX','oauth_callback':回调,'oauth_nonce':随机数,'oauth_signature_method': 'HMAC-SHA1','oauth_signature': 'XXXXXXXXXXXXXXXXXXXX','oauth_timestamp':时间戳,'oauth_version': '1.0'}
有了这个,我如何获取 oauth_token https://developer.vimeo.com/apis/advanced#oauth 在 Python 中?
有人可以指导我吗?
谢谢!
使用您发布的代码.最后读取 r.text
的结果应该会给你一个 oauth_token
和 oauth_token_secret
(以及一个 oauth_callback_confirmed 参数).>
你收到的其实是一个请求令牌,需要用户授权:
打开指向 https://vimeo.com/oauth/authorize?oauth_token=THE_OAUTH_TOKEN_YOU_JUST_RECEIVED
的网络浏览器.在那里登录,您将被重定向到您的回调.在回调 URL 的末尾,您将再次看到 oauth_token
和一个 oauth_verifier
参数,如下所示:
现在您可以继续获取访问令牌,这是您对 vimeo 执行完整 API 请求所需要的. 将 oauth_token 和 oauth_verifier 添加到您在链接的脚本中所做的类似请求中.当您签署您的请求时,您需要使用您的消费者和您的令牌进行签名: 并将此请求发送到 I want to integrate user's vimeo videos in my web application and I got this code in github https://gist.github.com/2944212 Using that code I can fetch oauth_signature value. Now I'm having this parameter. With that How can I fetch oauth_token https://developer.vimeo.com/apis/advanced#oauth in Python? Could anyone guide me? Thanks! Using the code you posted. Just reading the result of What you have received is in fact a request token, which needs to be authorized by a user: Open a web browser pointing to Now you can proceed to get the access token, which is what you need to do full API requests to vimeo. Add the oauth_token, and the oauth_verifier to a similar request as you did in the script you linked. When you sign your request you will need to sign it with both your consumer and your token: And send this request to the 这篇关于Python oauth2 - 发出请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!http://stage.bahai.us/apps/terrace/vimeo-callback?oauth_token=a9fb93ebef0fb42cbb96c92ff917b7ea&oauth_verifier=c7afdb2b65c1d77e0cf09687dcf09685ddc5a
req.sign_request(signature_method, consumer, token)
https://vimeo.com/oauth/access_token
端点.这应该会给你一个直接的响应,同样是通过阅读响应文本,包含你的访问令牌和访问令牌秘密.params = {
'oauth_consumer_key': 'XXXXXXXXXXXXXXXXXXXX',
'oauth_callback': callback,
'oauth_nonce': nonce,
'oauth_signature_method': 'HMAC-SHA1',
'oauth_signature': 'XXXXXXXXXXXXXXXXXXXX',
'oauth_timestamp': timestamp,
'oauth_version': '1.0'
}
r.text
at the end should give you a oauth_token
and oauth_token_secret
(as well as an oauth_callback_confirmed parameter).https://vimeo.com/oauth/authorize?oauth_token=THE_OAUTH_TOKEN_YOU_JUST_RECEIVED
. Log in there and you will be redirected to your callback. At the end of the callback URL you will see your oauth_token
again, and an oauth_verifier
parameter, something like this:http://stage.bahai.us/apps/terrace/vimeo-callback?oauth_token=a9fb93ebef0fb42cbb96c92ff917b7ea&oauth_verifier=c7afdb2b65c1d77e0cf09687ddc5a8d5
req.sign_request(signature_method, consumer, token)
https://vimeo.com/oauth/access_token
endpoint. This should give you a direct response, again by reading the response text, containing your access token and access token secret.