So, I thought I'd learn a bit about Chrome extension development by
making a small extension that just needs to send to Twitter. Funny
thing is, Chrome extensions aren't hard, getting OAuth to work is.

I got the oauth.js library linked from the site and tried
setting it up (
Problem is, every time I get a "Failed to validate oauth signature and
token" error.

I've checked signatures, and it seems OK, and even looked at the
headers that it's sending what is expected and the raw signature
string looks correct. I've used Google's signature checker and the
signature is right, even made an app in C# to confirm. I've checked my
time and it's OK.

I even tried the Chrome provided OAuth library, but not no avail. I've
hit a wall, I don't know what else to do.

Here's the snippet of code,
function getRequestToken() {
        var accessor = { consumerSecret: consumer.consumerSecret,
                                         consumerKey:    consumer.consumerKey };
        var message = { action: consumer.serviceProvider.requestTokenURL,
                                        method: "POST",
                                        parameters: []};
        message.parameters.push(['oauth_callback', 'oob']);"Starting OAuth requests");
        doOAuthCall( message, accessor, function(data, textStatus) {
                var list = OAuth.getParameterMap( OAuth.decodeForm(data) );
                consumer.token = list.oauth_token;
                consumer.tokenSecret = list.oauth_token_secret;

and I use a modified version of the doOAuthCall from OAuth Explorer,
function doOAuthCall( message, accessor, oncmp ) {
        OAuth.completeRequest(message, accessor);

        var bs = OAuth.SignatureMethod.getBaseString( message );
        var ah = OAuth.getAuthorizationHeader('OAuth',
message.parameters );
        var cg = OAuth.addToURL( message.action, message.parameters );

                'beforeSend': function(xhr) {
                        xhr.setRequestHeader("Authorization", ah)
                'error': function(req, err) { oncmp(req.responseText, err ) }
        jQuery.get( message.action, [], oncmp, 'text');

The Authorization header,
Authorization:OAuth realm="OAuth", oauth_callback="oob",
oauth_consumer_key="xxxxxxxxxxxxxxxxxxxxxx", oauth_version="1.0",
oauth_timestamp="1278129985", oauth_nonce="zBRCtf",
oauth_signature_method="HMAC-SHA1", oauth_signature="53drmjGf

Any help will be much appreciated, thanks :)

Reply via email to