This project is abandoned
Please use Arctic/lucia-auth as the currently maintained alternative.
Passport strategy for authenticating with osu! using the OAuth 2.0 API.
This module lets you authenticate using osu! in your Node.js applications. By plugging into Passport, osu! authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.
npm install passport-osu
The osu! authentication strategy authenticates users using a osu!
account and OAuth 2.0 tokens. The strategy requires a verify
callback, which
accepts these credentials and calls done
providing a user, as well as
options
specifying a client ID, client secret, and callback URL.
import OsuStrategy from 'passport-osu'; // or const OsuStrategy = require('passport-osu');
passport.use(new OsuStrategy({
clientID: OSU2_CLIENT_ID,
clientSecret: OSU2_CLIENT_SECRET,
callbackURL: "http://localhost:8000/auth/osu/callback"
}, (accessToken, refreshToken, profile, done) => {
User.findOrCreate({ osuId: profile.id }, function (err, user) {
return done(err, user);
});
}
));
If you're using this module in Javascript, please use new OsuStrategy.default(...);
instead.
Use passport.authenticate()
, specifying the 'osu'
strategy, to
authenticate requests.
For example, as route middleware in an Express application:
app.get('/auth/osu', passport.authenticate('osu'));
app.get('/auth/osu/cb', passport.authenticate('osu', { failureRedirect: '/' }), (req: Request, res: Response) => {
res.send("Success!");
});
For a complete, working example, refer to the login example.