passport-twitter-2
Advanced tools
Comparing version 0.0.5 to 0.0.6
{ | ||
"name": "passport-twitter-2", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Passport Strategy for Twitter API v2", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -12,14 +12,16 @@ # Passport-Twitter-2 | ||
#### Configure Strategy | ||
import { Strategy as TwitterStrategy } from 'passport-twitter-2'; | ||
passport.use(new TwitterStrategy({ | ||
clientID: TWITTER_CLIENT_ID, | ||
appKey: TWITTER_CLIENT_SECRET, | ||
callbackURL: "http://localhost:3000/auth/twitter/callback" | ||
}, | ||
function(accessToken, profile, done) { | ||
User.findOrCreate({ twitter: profile.id }, function (err, user) { | ||
return done(err, user); | ||
}); | ||
} | ||
)); | ||
```js | ||
import { Strategy as TwitterStrategy } from 'passport-twitter-2'; | ||
passport.use(new TwitterStrategy({ | ||
clientID: TWITTER_CLIENT_ID, | ||
appKey: TWITTER_CLIENT_SECRET, | ||
callbackURL: "http://localhost:3000/auth/twitter/callback" | ||
}, | ||
function(accessToken, profile, done) { | ||
User.findOrCreate({ twitter: profile.id }, function (err, user) { | ||
return done(err, user); | ||
}); | ||
} | ||
)); | ||
``` | ||
@@ -33,15 +35,20 @@ #### Authenticate Requests | ||
application: | ||
```js | ||
app.get('/auth/twitter', | ||
passport.authenticate('twitter')); | ||
app.get('/auth/twitter', | ||
passport.authenticate('twitter')); | ||
app.get('/auth/twitter/callback', | ||
passport.authenticate('twitter', { failureRedirect: '/login' }), | ||
function(req, res) { | ||
// Successful authentication, redirect home. | ||
res.redirect('/'); | ||
}); | ||
``` | ||
app.get('/auth/twitter/callback', | ||
passport.authenticate('twitter', { failureRedirect: '/login' }), | ||
function(req, res) { | ||
// Successful authentication, redirect home. | ||
res.redirect('/'); | ||
}); | ||
## Notes | ||
For Node.js 18+ you can skip installing node-fetch with `npm i passport-twitter-2--omit=optional` and use built-in fetch instead. | ||
For Node.js 18+ you can skip installing node-fetch with | ||
```bash | ||
npm i passport-twitter-2 --omit=optional | ||
``` | ||
and use built-in fetch instead. | ||
@@ -48,0 +55,0 @@ ## Credits |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
62
6890