var URL = 'https://api.twitter.com/oauth/request_token';
var parameters = {
oauth_consumer_key : 'key',
oauth_nonce : 'kllo9940pd9333jh',
oauth_timestamp : '1191242096',
oauth_signature_method : 'HMAC-SHA1',
oauth_version : '1.0',
};
var consumerSecret = 'key';
var encodedSignature = oauthSignature.generate('POST', URL, parameters, consumerSecret);
var callback = encodeURIComponent('127.0.0.1:3000');
var consumerkey = encodeURIComponent('key');
var oauthNonce = encodeURIComponent('kllo9940pd9333jh');
App.TwitterController = Ember.ObjectController.extend({
actions: {
loginTwitter: function() {
console.log('Event Clicked');
console.log(parameters);
console.log(encodedSignature);
console.log(URL);
console.log(consumerSecret);
console.log(callback);
console.log(oauthNonce);
return new Ember.RSVP.Promise(function(resolve, reject) {
Ember.$.ajax({
url: 'https://api.twitter.com/oauth/request_token',
type: 'POST',
contentType: "json",
headers: {
"Authorization": 'OAuth oauth_callback='+ callback +', oauth_consumer_key='+ consumerkey +', oauth_nonce='+ oauthNonce +', oauth_signature='+ encodedSignature +', oauth_signature_method="HMAC-SHA1", oauth_timestamp="1191242096", oauth_version="1.0"'
},
contentType: 'application/x-www-form-urlencoded'
}).then(function(response) {
console.log('Successed');
console.log(response);
resolve (response);
}, function(xhr, status, error) {
console.log(error);
console.log('In Error');
reject(error);
});
});
},
}
});
I above code is for request token from the twiiter but it give error Failed to validate oauth signature and token error occur. How I resolve this? Why this happen?
Is there problem in my oauth_signature my oauth_signature is j%2BkemjnrvI2%2BBERPE7hf6bTb7Ds%3D.