蟒蛇的oauth2 - 制作要求 [英] Python oauth2 - making request

查看:182
本文介绍了蟒蛇的oauth2 - 制作要求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要整合用户的VIMEO视频在我的web应用程序和我在github上 HTTPS此code:/ /gist.github.com/2944212 使用code,我可以取的 oauth_signature 值。

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.

现在我有这个参数。

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'
}

使用我如何可以获取的组oauth_token https://开头开发商。在Python vimeo.com/apis/advanced#oauth

With that How can I fetch oauth_token https://developer.vimeo.com/apis/advanced#oauth in Python?

任何人都可以指导我?

谢谢!

推荐答案

使用code您发布。只是读 r.text 的结果在年底应该给你一个组oauth_token oauth_token_secret (以及一个oauth_callback_confirmed参数)。

Using the code you posted. Just reading the result of r.text at the end should give you a oauth_token and oauth_token_secret (as well as an oauth_callback_confirmed parameter).

你所收到的是实际上是一个请求令牌,这需要由用户授权的:

What you have received is in fact a request token, which needs to be authorized by a user:

打开Web浏览器指向 https://vimeo.com/oauth/authorize?oauth_token=THE_OAUTH_TOKEN_YOU_JUST_RECEIVED 。登录那里,你将被重定向到您的回调。在回调URL的末尾,你会看到你的组oauth_token 再次,和 oauth_verifier 参数,像这样:

Open a web browser pointing to 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:

<$c$c>http://stage.bahai.us/apps/terrace/vimeo-callback?oauth_token=a9fb93ebef0fb42cbb96c92ff917b7ea&oauth_verifier=c7afdb2b65c1d77e0cf09687ddc5a8d5

现在您可以继续获得访问令牌,这是你需要做全面的API请求到Vimeo什么。

Now you can proceed to get the access token, which is what you need to do full API requests to vimeo.

该组oauth_token和oauth_verifier添加到类似的要求,你在你链接的剧本一样。当您注册您的要求,您将需要既您的消费者和你的令牌签名:

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:

req.sign_request(signature_method,消费,令牌)

和发送该请求到 https://vimeo.com/oauth/access_token 端点。这应该通过读取响应文本,包括您的访问令牌和访问令牌的秘密给你一个直接的回应,再次。

And send this request to the 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.

这篇关于蟒蛇的oauth2 - 制作要求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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