Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write Acess not working #87

Open
jacob-cross99 opened this issue Mar 29, 2017 · 2 comments
Open

Write Acess not working #87

jacob-cross99 opened this issue Mar 29, 2017 · 2 comments

Comments

@jacob-cross99
Copy link

I am working on building an oauth flow with PassportJS for Twitter. I am looking to use the 'write' permissions to follow a user through the oauth'd Twitter account upon oauth authentication. Only issue is it's only giving me read permissions. I've setup the Read/Write permission settings in the Twitter app dashboard and modified the requestTokenURL in the strategy parameters yet the page that says what permissions the server is requesting isn't showing any write permissions just read.

const express = require('express');
const passport = require('passport');
const Strategy = require('passport-twitter').Strategy;

passport.use(new Strategy({
  consumerKey: 'XXX',
  consumerSecret: 'XXX',
  requestTokenURL: 'https://api.twitter.com/oauth/request_token?x_auth_access_type=write',
  callbackURL: 'XXX/oauth/callback'
}, (token, tokenSecret, profile, cb) => {
  console.log(profile, token, tokenSecret);
  return cb(null, profile);
}));

passport.serializeUser((user, cb) => {
  cb(null, user);
});

passport.deserializeUser((obj, cb) => {
  cb(null, obj);
});

let app = express();
app.use(require('express-session')({ secret: 'keyboard cat', resave: true, saveUninitialized: true }));
app.use(passport.initialize());
app.use(passport.session());

app.get('/', (req, res) => {
  res.send('<html><body><center><a href="/oauth/twitter">Login with Twitter</a></center></body></html>');
});

app.get('/oauth/twitter', passport.authenticate('twitter'));

app.get('/oauth/callback', passport.authenticate('twitter', { failureRedirect: '/' }), (req, res) => {
  res.send('<html><body><center><h3>You are now following the account and have notifications on!</h3></center></body></html>');
});

app.listen(3000, '0.0.0.0', (err) => {
  if(err) throw err;
  console.log('Server is now running');
});
@jacob-cross99 jacob-cross99 changed the title Passport-Twitter Write Acess not working Write Acess not working Mar 29, 2017
@yamila-fraiman
Copy link

Any update?

@marswong
Copy link

marswong commented Dec 4, 2017

you can use the token and tokenSecret inside the Strategy callback to access Twitter's write API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants