0

How I can generate the oauth_signature and oauth_nonce in ember.js?

How I can pass Authorization Header in Ember.js?

App.TwitterController = Ember.ObjectController.extend({

    actions: {

        URL : ' https://api.twitter.com/oauth/request_token',
        parameters : {
            oauth_consumer_key : '',
            oauth_nonce : 'kllo9940pd9333jh',
            oauth_timestamp : '1191242096',
            oauth_signature_method : 'HMAC-SHA1',
            oauth_version : '1.0',
        },
        consumerSecret : '',

        encodedSignature : oauthSignature.generate('POST', URL, parameters, consumerSecret, tokenSecret),


        loginTwitter: function() {
            console.log('Event Clicked');
            return new Ember.RSVP.Promise(function(resolve, reject) {
            Ember.$.ajax({
                url:         'https://api.twitter.com/oauth/request_token',
                type:        'POST',
                headers: {
                    "Authorization": 'OAuth oauth_callback="http%3A%2F%2example.com%3A3005%2Ftwitter%2Fcallback", oauth_consumer_key="", oauth_nonce="kllo9940pd9333jh", 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);
            });
        });
        },
    }
});

Error is Failed to validate oauth signature and token

I am new to Ember.js. In above example i used the header, is this correct or not. If not then please tell me how I can use the authorization header in ember.js

How I can create the oauth_signature and oauth_nonce in ember.js. Any library?

It give error ' Reference: parameters is not defined'. Then When i comment the parameters code and also remove from function. then it give error ' Reference: consumerSecret is not define'.

I not want to give the consumer secret. Because in twitter documentation i have read only the callback url, oauth_signaturem oauth_nonce, consumer_key and version to request the token.

It not return the auth_token, oauth_secert. I want to access the auth_token etc when request_token url hits.

App.ApplicationController = Ember.Controller.extend({

    URL : ' https://api.twitter.com/oauth/request_token',

    parameters : {
            oauth_consumer_key : '',
            oauth_nonce : 'kllo9940pd9333jh',
            oauth_timestamp : '1191242096',
            oauth_signature_method : 'HMAC-SHA1',
            oauth_version : '1.0',
    },
    consumerSecret : '',

        // generates a RFC3986 encoded, BASE64 encoded HMAC-SHA1 hash
    encodedSignature : oauthSignature.generate('POST', URL, parameters, consumerSecret, tokenSecret),
});

I also create the properties in the ApplicationController and access in the twitterController but same error occurs.

This line also give error oauthSignature.generate methid return the signature but it give error. encodedSignature = oauthSignature.generate('POST', URL, parameters, consumerSecret, tokenSecret), });

when i change it to encodedSignature : oauthSignature.generate('POST', URL, parameters, consumerSecret, tokenSecret), });

error goes

Sohaib Ahmed
  • 31
  • 1
  • 6
  • `URL`, `parameters`, `consumerSecret` and `encodedSignature` seem to be properties, they don't belong in the `actions` hash. Only functions belong in `actions`, move the properties to the object's root. – Steve H. Oct 01 '14 at 01:41
  • Your question is "is this correct". What happened when you tried it? What did you expect to happen? You need to include those things in your question. You can clean up the question as I suggested above and then say what happened when you ran your application. – Steve H. Oct 01 '14 at 01:43
  • Please now see the question. – Sohaib Ahmed Oct 01 '14 at 02:03
  • How we create the oauth_signature in ember.js. any library steve – Sohaib Ahmed Oct 01 '14 at 02:21

0 Answers0