Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/MiraiSubject/passport-osu
osu! authentication strategy for Passport and Node.js.
https://github.com/MiraiSubject/passport-osu
authentication-strategy express-middleware nodejs osu osu-api passport-osu passportjs strategy
Last synced: 3 months ago
JSON representation
osu! authentication strategy for Passport and Node.js.
- Host: GitHub
- URL: https://github.com/MiraiSubject/passport-osu
- Owner: MiraiSubject
- License: mit
- Created: 2020-08-09T21:38:24.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-03T15:02:14.000Z (almost 2 years ago)
- Last Synced: 2024-04-24T16:37:50.172Z (7 months ago)
- Topics: authentication-strategy, express-middleware, nodejs, osu, osu-api, passport-osu, passportjs, strategy
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/passport-osu
- Size: 92.8 KB
- Stars: 8
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-osu-tournaments - passport-osu - osu! authentication strategy for Passport and Node.js. (Community Resources / Development)
README
# Passport-osu
[Passport](https://github.com/jaredhanson/passport) strategy for authenticating
with [osu!](https://osu.ppy.sh/) 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](http://www.senchalabs.org/connect/)-style middleware, including
[Express](http://expressjs.com/).## Install
```bash
npm install passport-osu
```## Usage
### Configure Strategy
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.```typescript
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.
#### Authenticate Requests
Use `passport.authenticate()`, specifying the `'osu'` strategy, to
authenticate requests.For example, as route middleware in an [Express](http://expressjs.com/)
application:```javascript
app.get('/auth/osu', passport.authenticate('osu'));app.get('/auth/osu/cb', passport.authenticate('osu', { failureRedirect: '/' }), (req: Request, res: Response) => {
res.send("Success!");
});
```## Examples
For a complete, working example, refer to the [login example](https://github.com/MiraiSubject/passport-osu/tree/master/example/login).
## References
- [Definitely Typed: passport-github2 types](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/passport-github2)
- [Passport-Github2](https://github.com/cfsghost/passport-github)
- [Passport-reddit README](https://github.com/Slotos/passport-reddit)## License
[The MIT License](http://opensource.org/licenses/MIT)