Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
badave committed Jan 10, 2013
1 parent 7837cb3 commit bef5b97
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions README.md
Expand Up @@ -37,19 +37,21 @@ Add to `dependencies`:
## And then...

All paths not contained in publicPaths will require an access token. The access token can be passed to a frontend client after the client is authenticated via some form of login. For example, making a POST to /login with email and password, verifying email and password are correct, and then passing the access token to the client. Here is some javascript for passing an access token to the client in JSON.
app.get('/login', function(req, res) {
var authenticate = require("authenticate");
// Insert user auth logic here
res.writeHead(200, {
"Content-Type": "application/json"
});
res.write(JSON.stringify({
"access_token": authenticate.serializeToken(client_id, user_id, extra_data) // extra data is optional
}));
res.end();
})

app.get('/login', function(req, res) {
var authenticate = require("authenticate");
// Insert user auth logic here
res.writeHead(200, {
"Content-Type": "application/json"
});
res.write(JSON.stringify({
"access_token": authenticate.serializeToken(client_id, user_id, extra_data) // extra data is optional
}));
res.end();
})

An access token embeds data into the request.

req.data.user_id // user id
req.data.client_id // A client id
req.data.date // date access token was created
Expand Down

0 comments on commit bef5b97

Please sign in to comment.