Reputation: 2422
I have an application where I have the user authenticate with Twitter and give my app access to their Twitter account. To do this, they click a button on the front end, which gets an oauth_token
on the server by going to Twitter with the application information. Then on the front end, after the user authenticates, it saves that token that comes back from the user authenticating.
The next step is to get the user's timeline. I know that the GET statuses/user_timeline
requires authentication. But my problem is that I don't know how to provide that authentication. (I'm using the oauth
library to do the authentication.) I've used created an OAuth Authorization header with the token and verifier that comes back after the user authenticates, and with the token and secret for the app I created at apps.twitter.com. Each time, when I make a GET request to the URL, I get an "Invalid or expired token" response.
I'm obviously missing a step in here...any suggestions on what that step is?
I've looked at several twittercommunity.com posts, as well as many here on SO, including this one
, which is what lead me to making the OAuth header in the way that I did.
Upvotes: 2
Views: 581
Reputation: 1157
I did this using node-twitter-api node module click here
var twitterAPI = require('node-twitter-api');
function twitter = new twitterAPI({
consumerKey: req.api_key,
consumerSecret: req.api_secret,
callback: req.cbUrl
});
twitter.statuses('update', {status: _tweet_msg}, req.body.auth.accessToken, req.body.auth.accessTokenSecret, function (error, data, response) {
if (error) {
res.send({data: 'Fail'});
} else {
res.send('success');
}
});
Upvotes: 1