Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: crodas/everyauth
base: 4e623d1c8a
...
head fork: crodas/everyauth
compare: 6c1248f639
Checking mergeability… Don't worry, you can still create the pull request.
  • 5 commits
  • 7 files changed
  • 0 commit comments
  • 2 contributors
Commits on Feb 02, 2012
@pirxpilot pirxpilot Added tripit OAuth module
Detailed documentation is here:
http://tripit.github.com/api/doc/v1/#authentication_section

Pretty standard OAuth implementation. The only problem is that redirect
URL is different oauthHost, hence redefining redirectToProviderAuth.
b4ae78c
Commits on Feb 03, 2012
@pirxpilot pirxpilot Add usage example for TripIt authentication 5e3178f
@pirxpilot pirxpilot Modify everyauth documentation for TripIt OAuth 185c6ff
@bnoguchi bnoguchi Merge pull request #170 from pirxpilot/tripit
Add TripIt (OAuth) authentication module
af9fcdc
@bnoguchi bnoguchi 0.2.30 6c1248f
View
32 README.md
@@ -38,6 +38,7 @@ So far, `everyauth` enables you to login via:
<tr> <td> <img src="https://github.com/meritt/everyauth/raw/vkontakte/media/vkontakte.ico" style="vertical-align:middle"> VKontakte (Russian Social Network) <td> <a href="https://github.com/meritt">Alexey Simonenko</a>
<tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/skyrock.ico" style="vertical-align:middle" width="16px" height="16px"> Skyrock <td> <a href="https://github.com/srod">Rodolphe Stoclin</a>
<tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/gowalla.ico" style="vertical-align:middle"> Gowalla <td> <a href="https://github.com/andykram">Andrew Kramolisch</a>
+ <tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/tripit.ico" style="vertical-align:middle"> TripIt <td> <a href="https://github.com/pirxpilot">Damian Krzeminski</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>
@@ -1616,6 +1617,37 @@ object whose parameter name keys map to description values:
everyauth.osm.configurable();
```
+## Setting up TripIt OAuth (1.0)
+
+Obtain consumer key and consumer secret for your app by [registering it](http://www.tripit.com/developer/create).
+Please note that TripIt is using _API Key_ and _API Secret_ terminology: use those values as describe below.
+
+```javascript
+var everyauth = require('everyauth')
+ , connect = require('connect');
+
+everyauth.tripit
+ .consumerKey('YOUR API KEY')
+ .consumerSecret('YOUR API SECRET')
+ .findOrCreateUser( function (sess, accessToken, accessSecret, tripitProfile) {
+ // find or create user logic goes here
+ })
+ .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);
+```
+
+
## Setting up OpenID protocol
OpenID protocol allows you to use an openid auth request. You can read more information about it here http://openid.net/
View
4 example/conf.js
@@ -87,4 +87,8 @@ module.exports = {
, consumerKey: 'Enter your consumer key here'
, consumerSecret: 'Enter your consumer secret here'
}
+ , tripit: {
+ consumerKey: 'a59bb58479f80e24dc6da1b1e61a107db743bc4c'
+ , consumerSecret: '41dc4c0c39ac3ab162269a79f399eb180f753c66'
+}
};
View
10 example/server.js
@@ -44,6 +44,7 @@ var usersByVkId = {};
var usersBySkyrockId = {};
var usersByEvernoteId = {};
var usersByAzureAcs = {};
+var usersByTripIt = {};
var usersByLogin = {
'brian@example.com': addUser({ login: 'brian@example.com', password: 'password'})
};
@@ -338,6 +339,15 @@ everyauth.evernote
})
.redirectPath('/');
+everyauth.tripit
+ .consumerKey(conf.tripit.consumerKey)
+ .consumerSecret(conf.tripit.consumerSecret)
+ .findOrCreateUser( function (sess, accessToken, accessTokenExtra, tripitProfile) {
+ var userId = tripitProfile['@attributes'].ref;
+ return usersByTripIt[userId] || (usersByTripIt[userId] = addUser('tripit', tripitProfile));
+ })
+ .redirectPath('/');
+
var app = express.createServer(
express.bodyParser()
, express.static(__dirname + "/public")
View
6 example/views/home.jade
@@ -70,6 +70,9 @@
#evernote-login
a(href='/auth/evernote', style='border: 0px')
img(src='http://www.evernote.com/about/media/img/logo.png')
+ #tripit-login
+ a(href='/auth/tripit', style='border: 0px')
+ img(src='http://www.tripit.com/images/logos/logo_90x40_trans.gif', title='Login with TripIt')
#openid-login
form#openid(action='/auth/openid')
label(for='openid_identifier') OpenID Identifier: &nbsp;
@@ -143,6 +146,9 @@
- if (everyauth.evernote)
h3 Evernote User Data
p= JSON.stringify(everyauth.evernote.user)
+ - if (everyauth.tripit)
+ h3 TripIt User Data
+ p= JSON.stringify(everyauth.tripit.user)
h3
a(href='/logout') Logout
View
46 lib/modules/tripit.js
@@ -0,0 +1,46 @@
+var oauthModule = require('./oauth')
+ , url = require('url');
+
+var tripitModule = module.exports =
+oauthModule.submodule('tripit')
+ .apiHost('https://api.tripit.com')
+ .oauthHost('https://api.tripit.com')
+ .entryPath('/auth/tripit')
+ .callbackPath('/auth/tripit/callback')
+ .redirectToProviderAuth( function (res, token) {
+ var redirectTo = 'https://www.tripit.com' + this.authorizePath() + '?oauth_token=' + token;
+ if (this.sendCallbackWithAuthorize()) {
+ redirectTo += '&oauth_callback=' + this.myHostname() + this.callbackPath();
+ }
+ res.writeHead(303, { 'Location': redirectTo });
+ res.end();
+ })
+ .fetchOAuthUser( function (accessToken, accessTokenSecret, params) {
+ var promise = this.Promise();
+ this.oauth.get(this.apiHost() + '/v1/get/profile/id/' + params.user_id + '/format/json',
+ accessToken, accessTokenSecret, function (err, data) {
+ if (err) {
+ return promise.fail(err);
+ }
+ var oauthUser = JSON.parse(data).Profile;
+ promise.fulfill(oauthUser);
+ });
+ return promise;
+ })
+ .authCallbackDidErr( function (req) {
+ var parsedUrl = url.parse(req.url, true);
+ return parsedUrl.query && !!parsedUrl.query.denied;
+ })
+ .handleAuthCallbackError( function (req, res) {
+ if (res.render) {
+ res.render(__dirname + '/../views/auth-fail.jade', {
+ errorDescription: 'The user denied your request'
+ });
+ } else {
+ // TODO Replace this with a nice fallback
+ throw new Error("You must configure handleAuthCallbackError if you are not using express");
+ }
+ })
+ .convertErr( function (data) {
+ return new Error(data.data.match(/<error>(.+)<\/error>/)[1]);
+ });
View
BIN  media/tripit.ico
Binary file not shown
View
2  package.json
@@ -1,7 +1,7 @@
{
"name": "everyauth",
"description": "Auth solution (password, facebook, & more) for your node.js Connect & Express apps",
- "version": "0.2.29",
+ "version": "0.2.30",
"homepage": "https://github.com/bnoguchi/everyauth/",
"repository": {
"type": "git",

No commit comments for this range

Something went wrong with that request. Please try again.