Saturday, 13 May 2017

How to get the Username from Twitter with oauth_verifier and oauth_token in Node.js?

Because until now, I haven't got any satisfying answer, maybe one can just change the code a little to get this done.

I used the following to authenticate to twitter. (( Should be clear that the consumerKey and secret are set elsewhere))

app.get('/auth/twitter', passport.authenticate('twitter', { scope : 'email' }));

app.get('/auth/twitter/callback',function(req,res){
            console.log('parameters')
            console.log('token = '+req.query.oauth_token)
            console.log('verifier = '+req.query.oauth_verifier)
            token = req.query.oauth_token
            verifier = req.query.oauth_verifier
            if(token){authenticated=true}  
            )  
            res.render('index.ejs',{token : token, authenticated: authenticated,list: oll})   

        });    

However, I never managed to get the username from the login and the problem is that token and verifier are changing with each login.

I tried to user https://api.twitter.com/1.1/account/verify_credentials.json and read the documentation several times but that turned out to be of no use.



via Matthias Liszt

No comments:

Post a Comment