开发者

oAuth : Simple javascript

开发者 https://www.devze.com 2023-03-23 01:00 出处:网络
I got the following info from another question: var url = \"...\"; var accessor = { token: \"...\", tokenSecret: \"...\",

I got the following info from another question:

 var url = "...";
 var accessor = {
 token: "...",
 tokenSecret: "...",
 consumerKey : "...",
 consumerSecret: "..."
 };

 var message = {
 action: url,
 method: "GET",
 parameters: {...}
 };

 OAuth.completeRequest(message, accessor);        
 OAuth.SignatureMethod.sign(message, accessor);
 url = url + '?' + OAuth.formEncode(message.parameters);

  // send request to 'url'
  ...

Now it says it needs a token. In order to get th开发者_StackOverflow社区e token I need a signature. In order to get the signature I need a token.

See the problem? Clearly I am misunderstanding something but what?

There is almost 0 documentation for javascript OAuth , so any help is appriciated.

(note:I am using the tumblr API if that helps)


The way OAuth 1.0 works, you first get a set of temporary credentials (also known as request token). When you ask for request tokens, you use an empty token and secret. The OAuth 1.0 RFC explains that in section 2.11:

When making the request, the client authenticates using only the client credentials. The client MAY omit the empty "oauth_token" protocol parameter from the request and MUST use the empty string as the token secret value.

Then you use the token received to send the user over to grant access and when you get it, you use the token + secret to ask for a new access token which you use to make API calls.

EHL

0

精彩评论

暂无评论...
验证码 换一张
取 消