Passport strategy for authenticating with MyAnimeList using the OAuth 2.0 API.
$ npm install passport-myanimelist
The MyAnimeList authentication strategy authenticates users via a MyAnimeList user account and OAuth 2.0 token(s). A MyAnimeList API client ID, secret and redirect URL must be supplied when using this strategy. The strategy also requires a verify
callback, which receives the access token and an optional refresh token, as well as a profile
which contains the authenticated MyAnimeList user's profile. The verify
callback must also call cb
providing a user to complete the authentication.
var MyAnimeListStrategy = require("passport-myanimelist").Strategy;
passport.use(
new MyAnimeListStrategy(
{
clientID: "id",
clientSecret: "secret",
callbackURL: "callbackURL",
},
function (accessToken, refreshToken, profile, cb) {
User.findOrCreate({ id: profile.id }, function (err, user) {
return cb(err, user);
});
}
)
);
Use passport.authenticate()
, specifying the 'myanimelist'
strategy, to
authenticate requests.
For example, as route middleware in an Express application:
app.get('/auth/myanimelist',
passport.authenticate('myanimelist'));
app.get('/auth/myanimelist/callback',
passport.authenticate('myanimelist', { failureRedirect: '/login', successRedirect : '/' }));
For a complete, working example, refer to the example.
- Sarukei
- Jared Hanson (passport-oauth2)