Box.net |
@@ -794,7 +796,7 @@ everyauth.password
var promise = this.Promise()
, password = newUserAttrs.password;
- delete newUserAttrs[password]; // Don't store password
+ delete newUserAttrs.password; // Don't store password
newUserAttrs.salt = bcrypt.genSaltSync(10);
newUserAttrs.hash = bcrypt.hashSync(password, salt);
@@ -1065,10 +1067,10 @@ var everyauth = require('everyauth')
everyauth.google
.appId('YOUR CLIENT ID HERE')
.appSecret('YOUR CLIENT SECRET HERE')
- .scope('https://www.google.com/m8/feeds') // What you want access to
+ .scope('https://www.googleapis.com/auth/userinfo.profile') // What you want access to
.handleAuthCallbackError( function (req, res) {
// If a user denies your app, Google will redirect the user to
- // /auth/facebook/callback?error=access_denied
+ // /auth/google/callback?error=access_denied
// This configurable route handler defines how you want to respond to
// that.
// If you do not configure this, everyauth renders a default fallback
@@ -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
diff --git a/lib/modules/github.js b/lib/modules/github.js
index 927a9861..15390ee6 100644
--- a/lib/modules/github.js
+++ b/lib/modules/github.js
@@ -7,7 +7,7 @@ oauthModule.submodule('github')
})
.oauthHost('https://github.com')
- .apiHost('https://github.com/api/v2/json')
+ .apiHost('https://api.github.com')
.authPath('/login/oauth/authorize')
.accessTokenPath('/login/oauth/access_token')
@@ -21,9 +21,9 @@ oauthModule.submodule('github')
.fetchOAuthUser( function (accessToken) {
var p = this.Promise();
- this.oauth.get(this.apiHost() + '/user/show', accessToken, function (err, data) {
+ this.oauth.get(this.apiHost() + '/user', accessToken, function (err, data) {
if (err) return p.fail(err);
- var oauthUser = JSON.parse(data).user;
+ var oauthUser = JSON.parse(data);
p.fulfill(oauthUser);
})
return p;
diff --git a/lib/modules/openid.js b/lib/modules/openid.js
index 6f083fd8..65d89c69 100644
--- a/lib/modules/openid.js
+++ b/lib/modules/openid.js
@@ -50,11 +50,18 @@ everyModule.submodule('openid')
if (!this._myHostname || this._alwaysDetectHostname) {
this.myHostname(extractHostname(req));
}
-
+
+ var self = this;
+ var p = this.Promise();
+
this.relyingParty.authenticate(req.query[this.openidURLField()], false, function(err,authenticationUrl){
if(err) return p.fail(err);
- this.redirect(res, authenticationUrl);
+
+ self.redirect(res, authenticationUrl);
});
+
+ p.fulfill();
+ return p;
})
.getSession( function(req) {
return req.session;
diff --git a/lib/modules/smarterer.js b/lib/modules/smarterer.js
new file mode 100644
index 00000000..78716faf
--- /dev/null
+++ b/lib/modules/smarterer.js
@@ -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);
+ });
diff --git a/media/smarterer.ico b/media/smarterer.ico
new file mode 100644
index 00000000..d676b1f3
Binary files /dev/null and b/media/smarterer.ico differ
|