问题
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.
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'
}
With that How can I fetch oauth_token https://developer.vimeo.com/apis/advanced#oauth in Python?
Could anyone guide me?
Thanks!
回答1:
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:
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:
http://stage.bahai.us/apps/terrace/vimeo-callback?oauth_token=a9fb93ebef0fb42cbb96c92ff917b7ea&oauth_verifier=c7afdb2b65c1d77e0cf09687ddc5a8d5
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:
req.sign_request(signature_method, consumer, 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.
来源:https://stackoverflow.com/questions/11070885/python-oauth2-making-request