Skip to content

Instantly share code, notes, and snippets.

@apeque
Created July 20, 2016 05:25
Show Gist options
  • Select an option

  • Save apeque/1e2046b0d6ed0e1addb0e784a161c81f to your computer and use it in GitHub Desktop.

Select an option

Save apeque/1e2046b0d6ed0e1addb0e784a161c81f to your computer and use it in GitHub Desktop.
AWS Cognito Twitter Auth
var awssdk = require('aws-sdk');
awssdk.config = new awssdk.Config();
awssdk.config.accessKeyId = self.config.aws.id;
awssdk.config.secretAccessKey = self.config.aws.secret;
awssdk.config.region = self.config.aws.region;
// token and secret variables obtained from Twitter
// oAuth flow; same tokens work to query Twitter REST API.
var params = {
IdentityPoolId: self.config.aws.pool,
Logins: {
'api.twitter.com': token + ';' + secret
}
};
awssdk.config.credentials = new awssdk.CognitoIdentityCredentials(params);
awssdk.config.credentials.get(function(err){
console.log(err);
});
// Error: NotAuthorizedException: Invalid login token.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment