How do I make a twitter OAuth Echo verification call?
Asked Answered
H

1

5

I'm using this npm package to do OAuth Echo verification of users against twitter: https://github.com/ciaranj/node-oauth

Does anyone have an example of how to use this package to verify a users credentials?

I'm getting the X-Auth-Service-Provider & X-Verify-Credentials-Authorization from the iOS app correctly as far as I can tell, but I'm having trouble using those headers with this package.

Here's the OAuthEcho constructor:

var oauthEcho = new OAuthEcho(
        "https://twitter.com",
        "https://api.twitter.com/1.1/account/verify_credentials.json",
        app.config.twitter.consumer_key,
        app.config.twitter.consumer_private_key,
        "1.0A",
        "HMAC-SHA1"
    );

Any help would really be appreciated!

Thanks!!

Humidifier answered 14/12, 2014 at 7:0 Comment(0)
H
8

WOW, I was going about this all wrong. I didn't actually need the oauth module. I needed the request module to make a simple GET call to twitters api.

// Setup the request object for OAuth Echo to twitter
var options = {
  url: 'https://api.twitter.com/1.1/account/verify_credentials.json',
  headers: {
    'Authorization': req.headers['x-verify-credentials-authorization']
  }
};

// Make the request
request(options, function (error, response, body) {
  if (!error && response.statusCode == 200) {

    // If twitter responds with a 200, the echo call was authorized

    // TODO: do stuff

    next();
  } else {
    res.send(401, 'Unauthorized');
    next();
  }
});
Humidifier answered 16/12, 2014 at 3:38 Comment(2)
Are you able to make that request using Postman extension on Chrome?Mukul
I have been. For me, using digits, the endpoint was https://api.digits.com/1.1/sdk/account.jsonConnect

© 2022 - 2024 — McMap. All rights reserved.