From ce5ad68026cf27c85a5674c4690126cfc0cdf8f8 Mon Sep 17 00:00:00 2001 From: Avinash Dwarapu Date: Sun, 30 Mar 2014 00:40:41 +0100 Subject: [PATCH 1/2] Add example to readme --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index b9ef664..4d1550c 100644 --- a/README.md +++ b/README.md @@ -521,6 +521,28 @@ var instagram = authom.createServer({ }) ``` +### Reddit ([create an app](https://ssl.reddit.com/prefs/apps/)) + +Options: + +- `service`: "reddit" +- `id`: the application's `CLIENT ID` +- `secret`: the application's `CLIENT SECRET` +- `state`: Unguessable random string. +- `scope` (optional): the scopes requested by your application + +Example: + +```javascript +var reddit = authom.createServer({ + service: "reddit", + id: "hG5c04ZOk0UngQ", + secret: "mdJoGP4ayA9M7NdBiKxZUyewz7M", + state: "unguessable-random-string", + scope: "identity" +}) +``` + ### SoundCloud ([create an app](http://soundcloud.com/you/apps/new)) Options: From 5b9a5f85e679fb4986ae2d29f5929087088234f4 Mon Sep 17 00:00:00 2001 From: Fedor Shubin Date: Wed, 14 May 2014 21:34:33 +0400 Subject: [PATCH 2/2] Add state parameter functionality to access token request #55 --- lib/services/oauth2.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/services/oauth2.js b/lib/services/oauth2.js index 2fcf384..55192a3 100644 --- a/lib/services/oauth2.js +++ b/lib/services/oauth2.js @@ -75,6 +75,12 @@ OAuth2.prototype.onRequest = function(req, res) { } OAuth2.prototype.onStart = function(req, res) { + if (req.url.query.state) { + this.code.query.state = req.url.query.state; + delete req.url.search + delete req.url.query.state; + } + this.code.query.redirect_uri = url.format(req.url) res.writeHead(302, {Location: url.format(this.code)})