使用2leg oauth令牌调用Bitbucket REST API [英] Call Bitbucket REST API using 2leg oauth token
问题描述
我正在尝试使用两足式oauth身份验证来调用bitbucket的api.
I am trying to call bitbucket's api using 2-legged oauth authentication.
我打电话
https://bitbucket.org/!api/1.0/oauth/request_token
使用我的oauth机密和密钥并获得以下信息:
with my oauth secret and key and get the following:
oauth_token_secret=<token_secret>&oauth_token=<token>&oauth_callback_confirmed=true
如何使用它来调用api函数,例如
How can I use this to call an api function, such as
https://bitbucket.org/api/1.0/user
推荐答案
收到访问令牌&机密,当您发送请求时,添加一个(Authorization)标头为
After you have received accesstoken & secret, when you send the request add a (Authorization) Header as,
Authorization: OAuth oauth_consumer_key="<YourKey>",oauth_signature_method="HMAC-SHA1",oauth_timestamp="<TIMESTAMP>",oauth_nonce="2694561796",oauth_version="1.0",oauth_signature="<Signature>"
在哪里
TIMESTAMP =当前时间(毫秒) oauth_nonce随机数
TIMESTAMP= current epoch (ms) oauth_nonce random number
重要的是oauth_signature
在这里通读如何生成,
在发送请求之前必须预先计算签名.这样就可以了.
Signature has to be precalculated before sending the request. And this will do it.
要对其进行测试,可以在此处进行试用, Apigee Bitbucket API控制台
To test it you can tryout it here, Apigee Bitbucket API Console
PS:Bit Bucket使用以漏洞闻名的OAuth 1.0很奇怪.
PS: Its weird that Bit Bucket uses OAuth 1.0, well known for its vulnerabilities.
这篇关于使用2leg oauth令牌调用Bitbucket REST API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!