passport-zendesk
v0.0.6
Published
Zendesk authentication strategy for Passport.
Downloads
6,246
Maintainers
Readme
passport-zendesk
Zendesk OAuth2 strategy for Passport.
⚠️ Warning
This package does not support all of the currently mandated OAuth 2.0 best practices documented here. Notably, there is no PKCE support, and the simplified passport.authenticate middleware approach does not facilitate refresh tokens.
Install
$ npm install passport-zendeskUsage
Configuration
var passport = require('passport');
var ZendeskStrategy = require('passport-zendesk').Strategy;
passport.use(new ZendeskStrategy({
subdomain: 'yourZendeskSubdomain',
clientID: 'yourClientIdentifier',
clientSecret: 'yourClientSecret',
callbackURL: 'https://www.example.net/auth/zendesk/callback',
state: true
},
function(accessToken, refreshToken, profile, done) {
done(err, user);
}
));Authenticate Requests
Use passport.authenticate(), specifying the 'zendesk' strategy to
authenticate requests.
For example, as route middleware in an Express application:
app.get('/auth/zendesk',
passport.authenticate('zendesk'));
app.get('/auth/zendesk/callback',
passport.authenticate('zendesk', { failureRedirect: '/login' }),
function(req, res) {
// Successful authentication, redirect home.
res.redirect('/');
});Using a Global Zendesk OAuth Client
If you've set up a global Zendesk OAuth Client and you wish to authenticate with multiple Zendesk subdomains, passport-zendesk will look for a subdomain parameter in the query string and the post body. Using the configuraiton specified above, a login link for example.zendesk.com would look like this:
<a href="/auth/zendesk?subdomain=example">Login with example.zendesk.com</a>You may also specify the subdomain explicitly in the authenticate() options:
app.get('/auth/zendesk',
passport.authenticate('zendesk', { subdomain: 'example'}));Examples
For a complete, working sample: login example.
