Skip to content

Commit 0b08206

Browse files
committed
📓 adding usage info
1 parent 0bf10c1 commit 0b08206

File tree

1 file changed

+54
-1
lines changed

1 file changed

+54
-1
lines changed

readme.md

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,58 @@
11
# Onscribe for Passport.js
22

3-
A node module to authenticate with onscribe using passport.js
3+
[Passport](http://passportjs.org/) strategy for authenticating with [Onscribe](https://onscri.be/) using the OAuth 2.0 API.
44

5+
This module lets you authenticate using Onscribe in your Node.js applications.
6+
7+
By plugging into Passport, Onscribe 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/).
8+
9+
## Install
10+
```
11+
npm install passport-onscribe
12+
```
13+
14+
## Usage
15+
16+
#### Configure Strategy
17+
18+
The Onscribe authentication strategy authenticates users using a Onscribe 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.
19+
```
20+
passport.use(new OnscribeOAuth2Strategy({
21+
clientID: CLIENT_ID,
22+
clientSecret: CLIENT_SECRET,
23+
callbackURL: "https://www.example.net/auth/onscribe/callback"
24+
},
25+
function(accessToken, refreshToken, profile, done) {
26+
User.findOrCreate({ providerId: profile.id }, function (err, user) {
27+
return done(err, user);
28+
});
29+
}
30+
));
31+
```
32+
33+
#### Authenticate Requests
34+
35+
Use `passport.authenticate()`, specifying the `'onscribe'` strategy, to authenticate requests.
36+
37+
For example, as route middleware in an [Express](http://expressjs.com/) application:
38+
39+
```
40+
app.get('/auth/onscribe',
41+
passport.authenticate('onscribe'));
42+
43+
app.get('/auth/onscribe/callback',
44+
passport.authenticate('onscribe', { failureRedirect: '/login' }),
45+
function(req, res) {
46+
// Successful authentication, redirect home.
47+
res.redirect('/');
48+
});
49+
```
50+
51+
## Credits
52+
53+
Initiated by [Makis Tracend](http://github.com/tracend)
54+
55+
Part of [Onscribe](http://onscri.be/) by [K&D Interactive](http://kdi.co/)
56+
57+
Released under the [MIT license](http://makesites.org/licenses/MIT)
558

0 commit comments

Comments
 (0)