Skip to content

balthazar/passport-twitchalerts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

passport-twitchalerts

Passport strategy for OAuth 2.0 authentication with TwitchAlerts

npm i -S passport-twitchalerts

Usage

As stated in the OAuth docs, access tokens expires after 60 minutes, and you'll need to regenerate one using the provided refresh token if you need to authenticate requests past this date.

Since TwitchAlerts doesn't provide an endpoint to get basic user informations, the profile variable will always be an empty object. The only way to identify a user resides in the refreshToken.

A scope is required, all scopes are available here.

passport.use(new TwitchAlertStrategy({
  clientID: CLIENT_ID,
  clientSecret: CLIENT_SECRET,
  callbackURL: 'http://127.0.0.1:3000/auth/callback',
  scope: ['donations.create', 'alerts.create']
}, function (accessToken, refreshToken, profile, done) {
  done(null, true)
}))

Authentication

Use passport.authenticate(), specifying the twitchalerts strategy, to authenticate requests.

app.get('/auth', passport.authenticate('twitchalerts'))

app.get('/callback', passport.authenticate('twitchalerts', { failureRedirect: '/' }), function (req, res) {
  res.redirect('/')
})

About

📺 Passport strategy for TwitchAlerts

Resources

Stars

Watchers

Forks

Packages

No packages published