Permalink
Browse files

Merge pull request #281 from kaizenpack/master

include smarterer oauth
  • Loading branch information...
2 parents fd7d567 + f792d7a commit 784547fd8f5a89ceb839631e5d8a0ac780e5f41d @bnoguchi committed Jun 13, 2012
Showing with 66 additions and 0 deletions.
  1. +36 −0 README.md
  2. +30 −0 lib/modules/smarterer.js
  3. BIN media/smarterer.ico
View
@@ -52,6 +52,8 @@ So far, `everyauth` enables you to login via:
<td> <a href="http://github.com/wnadeau">Winfred Nadeau</a>
<tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/mendeley.ico" style="vertical-align:middle"> Mendeley
<td> <a href="https://github.com/edy-b">Eduard Baun</a>
+ <tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/smarterer.ico" style="vertical-align:middle"> Smarterer
+ <td> <a href="https://github.com/kaizenpack">kaizenpack</a>
</tbody>
<tbody id=misc>
<tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/box.ico" style="vertical-align:middle"> Box.net <td>
@@ -2195,6 +2197,40 @@ connect(
).listen(3000);
```
+### Smarterer
+
+You will need to register for an app id [here](http://www.smarterer.com/). Implementation details follow the same pattern as with other
+oauth2 implementations.
+
+```javascript
+
+var everyauth = require('everyauth')
+ , connect = require('connect');
+
+everyauth.smarterer
+ .appId('YOUR APP ID')
+ .appSecret('YOUR APP SECRET')
+ .findOrCreateUser(function(session, accessToken, accessTokenSecret, userData) {
+ // find or create user logic goes here
+ // userData.userName will contain the smarterer username for the authenticated user
+ // userData.badges will contain the scores on quizes
+ })
+ .redirectPath('/');
+
+var routes = function (app) {
+ // Define your routes here
+};
+
+connect(
+ connect.bodyParser()
+ , connect.cookieParser()
+ , connect.session({secret: 'whodunnit'})
+ , everyauth.middleware()
+ , connect.router(routes);
+).listen(3000);
+```
+
+
### Box.net
```javascript
View
@@ -0,0 +1,30 @@
+var oauthModule = require('./oauth2')
+ , querystring= require('querystring');
+
+var smarterer = module.exports =
+oauthModule.submodule('smarterer')
+ .oauthHost('https://smarterer.com')
+ .apiHost('https://smarterer.com')
+
+ .entryPath('/auth/smarterer')
+ .callbackPath('/auth/smarterer/callback')
+
+ .authQueryParam('callback_url', function() {
+ return this._myHostname + this._callbackPath;
+ })
+
+ .accessTokenParam('grant_type', 'authorization_code')
+
+
+ .fetchOAuthUser( function (accessToken) {
+ var p = this.Promise();
+ this.oauth.get(this.apiHost() + '/api/badges', accessToken, function (err, data) {
+ if (err) return p.fail(err.error_message);
+ var oauthUser = JSON.parse(data);
+ p.fulfill(oauthUser);
+ })
+ return p;
+ })
+ .convertErr( function (data) {
+ return new Error(data.error_message);
+ });
View
Binary file not shown.

0 comments on commit 784547f

Please sign in to comment.