Permalink
Browse files

Merge branch 'master' of https://github.com/akinsella/everyauth into …

…akinsella-master

Conflicts:
	README.md
	example/conf.js
	example/server.js
	example/views/home.jade
  • Loading branch information...
bnoguchi committed Aug 8, 2012
2 parents 8c11710 + 950559d commit c9c8da4021f0c5cf664915349d2c865a598f1706
Showing with 96 additions and 5 deletions.
  1. +2 −0 .gitignore
  2. +31 −0 README.md
  3. +9 −5 example/conf.js
  4. +9 −0 example/server.js
  5. +6 −0 example/views/home.jade
  6. +39 −0 lib/modules/runkeeper.js
  7. BIN media/runkeeper.ico
View
@@ -5,3 +5,5 @@ issues
IRC.md
playground.js
CHANGES
npm-debug.log
.idea
View
@@ -54,6 +54,8 @@ So far, `everyauth` enables you to login via:
<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>
<tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/runkeeper.ico" style="vertical-align:middle"> RunKeeper
<td> <a href="https://github.com/akinsella">Alexis Kinsella</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>
@@ -2116,6 +2118,35 @@ connect(
).listen(3000);
```
### RunKeeper OAuth (2.0)
You will first need to [register your application](http://runkeeper.com/partner/applications) to get the appId and appSecret.
```javascript
everyauth.runkeeper
.appId('YOUR CONSUMER KEY HERE')
.consumerSecret('YOUR CONSUMER SECRET HERE')
.findOrCreateUser( function (sess, accessToken, accessSecret, user) {
// find or create user logic goes here
//
// e.g.,
// return usersByRunKeeperId[user.userID] || (usersByRunKeeperId[user.userID] = user);
})
.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);
```
### OpenID protocol
OpenID protocol allows you to use an openid auth request. You can read more information about it here http://openid.net/
View
@@ -119,9 +119,13 @@ module.exports = {
, mendeley: {
consumerKey: 'Enter your consumer key here'
, consumerSecret: 'Enter your consumer secret here'
}
, weibo: {
appId: '3350967939'
, appSecret: 'ef7f0a836d0ef315dca53e8d73816cc0'
}
}
, weibo: {
appId: '3350967939'
, appSecret: 'ef7f0a836d0ef315dca53e8d73816cc0'
}
, runkeeper: {
appId: 'Enter your client/app id here'
, appSecret: 'Enter your client/app secret here'
}
};
View
@@ -53,6 +53,7 @@ var usersMailruId = {};
var usersByMendeleyId = {};
var usersByDcId = {};
var usersByWeiboId = {};
var usersByRunKeeperId = {};
var usersByLogin = {
'brian@example.com': addUser({ login: 'brian@example.com', password: 'password'})
};
@@ -389,6 +390,14 @@ everyauth.mendeley
})
.redirectPath('/');
everyauth.runkeeper
.appId(conf.runkeeper.appId)
.appSecret(conf.runkeeper.appSecret)
.findOrCreateUser(function(sess, accessToken, accessSecret, user) {
return usersByRunKeeperId[user.userID] || (usersByRunKeeperId[user.userID] = addUser('runkeeper', user));
})
.redirectPath('/');
everyauth
.soundcloud
.appId(conf.soundcloud.appId)
View
@@ -86,6 +86,9 @@
#mendeley-login
a(href='/auth/mendeley', style='border: 0px')
img(src='http://d1rktifm8krpj.cloudfront.net/graphics/commonnew/logo-mendeley_1248201417297118.png', title='Login with Mendeley')
#runkeeper-login
a(href='/auth/runkeeper', style='border: 0px')
img(src='http://d2b4ufapzmnxpw.cloudfront.net/build/3572/static/kronos/images/logo.png', title='Login with Runkeeper')
#openid-login
form#openid(action='/auth/openid')
label(for='openid_identifier') OpenID Identifier: &nbsp;
@@ -185,5 +188,8 @@
p= JSON.stringify(everyauth.dailycred.user.email)
- if (everyauth['weibo'])
p= JSON.stringify(everyauth.weibo.user)
- if (everyauth.runkeeper)
h3 Runkeeper User Data
p= JSON.stringify(everyauth.runkeeper.user)
h3
a(href='/logout') Logout
View
@@ -0,0 +1,39 @@
var oauthModule = require('./oauth2')
, request = require('request');
var runkeeper = module.exports =
oauthModule.submodule('runkeeper')
.configurable({
scope: 'specify types of access: (no scope), non-expiring'
})
.apiHost('https://api.runkeeper.com')
.oauthHost('https://runkeeper.com')
.authPath('/apps/authorize')
.accessTokenPath('/apps/token')
.entryPath('/auth/runkeeper')
.callbackPath('/auth/runkeeper/callback')
.authQueryParam('response_type', 'code')
.authQueryParam('scope', function () {
return this._scope && this.scope();
})
.accessTokenHttpMethod('post')
.postAccessTokenParamsVia('data')
.accessTokenParam('grant_type', 'authorization_code')
.fetchOAuthUser(function (accessToken) {
console.log("Access Token: ", accessToken);
var promise = this.Promise();
request.get({
url: this.apiHost() + '/user'
, headers: {
'Authorization': 'Bearer ' + accessToken
}
}, function (err, res, body) {
if (err) return promise.fail(err);
if (parseInt(res.statusCode / 100, 10) !== 2) {
return promise.fail(body);
}
return promise.fulfill(JSON.parse(body));
});
return promise;
});
View
BIN +1.37 KB media/runkeeper.ico
Binary file not shown.

0 comments on commit c9c8da4

Please sign in to comment.