[英]OAuth Request Token Error:401 in flickr
I'm developing a mobile application for uploading pictures to flickr. 我正在开发一个移动应用程序,用于将图片上传到flickr。 But I can't even do the first step ie.,request token successfully.
但是我什至无法完成第一步,即成功请求令牌。 I signed the the base url and added the signature parameter to the code.
我对基本URL进行了签名,并将签名参数添加到了代码中。 I used the
http://oauth.googlecode.com/svn/code/javascript/oauth.js
and http://oauth.googlecode.com/svn/code/javascript/sha1.js
libraries in this other than AngularJS. 除了AngularJS,我还使用了
http://oauth.googlecode.com/svn/code/javascript/oauth.js
和http://oauth.googlecode.com/svn/code/javascript/sha1.js
库。 Sent the GET request as follows. 发送GET请求如下。
$scope.test=function(){
var preURL="http://www.flickr.com/services/oauth/request_token";
var accessor = {
consumerSecret: "a3439ab5915a03e4c",
tokenSecret : ""
};
var message = {
method: "GET",
action: preURL,
parameters: OAuth.decodeForm("oauth_callback=http%3A%2F%2Fwww.flickr.com")
};
message.parameters.push(["oauth_version", "1.0"]);
message.parameters.push(["oauth_consumer_key", "1cfb4bb9b0e0bec71554e66da9da4582"]);
message.parameters.push(["oauth_timestamp", OAuth.timestamp()]);
message.parameters.push(["oauth_nonce", OAuth.nonce(11)]);
message.parameters.push(["oauth_signature_method", "HMAC-SHA1"]);
OAuth.SignatureMethod.sign(message, accessor);
console.log("signatureBaseString" + OAuth.SignatureMethod.getBaseString(message));
console.log("signature" + OAuth.getParameter(message.parameters, "oauth_signature"));
var requestTokenURL=OAuth.addToURL(preURL,message.parameters);
console.log(requestTokenURL);
$http({
method: message.method,
url: requestTokenURL
}).
success(function(data, status, headers, config) {
console.log("success");
}).
error(function(data, status, headers, config) {
console.log("error");
});
}
An error is occuring with the following Network status: 以下网络状态发生错误:
GET http://www.flickr.com/services/oauth/request_tok...1&oauth_signature=h0pdL6ZzYqGnGsrHbqjwFCIGg2Y%3D
401 Unauthorized
I logged the following parameters in console. 我在控制台中记录了以下参数。
signatureBaseString: signatureBaseString:
GET&http%3A%2F%2Fwww.flickr.com%2Fservices%2Foauth%2Frequest_token&oauth_callback%3Dhttp%253A%252F%252Fwww.google.com%26oauth_consumer_key%3D1cfb4bb9b0e0bec71554e66da9da4582%26oauth_nonce%3DzKxKd3VJxEB%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1389180736%26oauth_version%3D1.0
Signature 签名
h0pdL6ZzYqGnGsrHbqjwFCIGg2Y=
RequestTokenURL RequestTokenURL
http://www.flickr.com/services/oauth/request_token?oauth_callback=http%3A%2F%2Fwww.google.com&oauth_version=1.0&oauth_consumer_key=1cfb4bb9b0e0bec71554e66da9da4582&oauth_timestamp=1389180736&oauth_nonce=zKxKd3VJxEB&oauth_signature_method=HMAC-SHA1&oauth_signature=h0pdL6ZzYqGnGsrHbqjwFCIGg2Y%3D
I entered the RequestTokenURL in browser and got this result: 我在浏览器中输入了RequestTokenURL并得到了以下结果:
oauth_problem=signature_invalid&debug_sbs=GET&http%3A%2F%2Fwww.flickr.com%2Fservices%2Foauth%2Frequest_token&oauth_callback%3Dhttp%253A%252F%252Fwww.google.com%26oauth_consumer_key%3D1cfb4bb9b0e0bec71554e66da9da4582%26oauth_nonce%3D6XctoZTWmaH%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1389181211%26oauth_version%3D1.0
This javascript library might help you on OAuth's stuff: oauth-1.0a 这个javascript库可能会帮助您了解OAuth的内容: oauth-1.0a
It support both client side and node.js 它同时支持客户端和node.js
Cheers 干杯
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.