Skip to content
Browse files

Added examples

  • Loading branch information...
1 parent b41ec0b commit 9b491184058255b5aa6fbbdad0eda5a486fba4ff @slickplaid slickplaid committed
Showing with 27 additions and 9 deletions.
  1. +4 −0 example/conf.js
  2. +12 −0 example/server.js
  3. +3 −0 example/views/home.jade
  4. +8 −9 lib/modules/{vimeo.js → justintv.js}
View
4 example/conf.js
@@ -39,6 +39,10 @@ module.exports = {
consumerKey: 'uhfqnbely5stdtm'
, consumerSecret: 'jr7ofuwo32l7vkd'
}
+ , vimeo: {
+ consumerKey: 'Enter your consumer key here'
+ , consumerSecret: 'Enter your consumer secret here'
+ }
, box: {
apiKey: '5hl66lbfy0quj8qhhzcn57dflb55y4rg'
}
View
12 example/server.js
@@ -4,6 +4,7 @@ var express = require('express')
everyauth.debug = true;
+var usersByVimeoId = {};
var usersByDropboxId = {};
var usersByFbId = {};
var usersByTwitId = {};
@@ -204,6 +205,17 @@ everyauth
})
.redirectPath('/')
+everyauth
+ .vimeo
+ .myHostname('http://local.host:3000')
+ .consumerKey(conf.vimeo.consumerKey)
+ .consumerSecret(conf.vimeo.consumerSecret)
+ .findOrCreateUser( function (sess, accessToken, accessSecret, vimeoUser) {
+ return usersByVimeoId[vimeoUser.id] ||
+ (usersByVimeoId[vimeoUser.id] = vimeoUser);
+ })
+ .redirectPath('/')
+
everyauth.box
.apiKey(conf.box.apiKey)
.findOrCreateUser( function (sess, authToken, boxUser) {
View
3 example/views/home.jade
@@ -39,6 +39,9 @@
#dropbox-login
a(href='/auth/dropbox', style='border: 0px')
img(src='https://www.dropbox.com/static/16890/images/logo.png')
+ #vimeo-login
+ a(href='/auth/vimeo', style='border: 0px')
+ img(src='http://a.vimeocdn.com/images/logo_vimeo.png')
#box-login
a(href='/auth/box', style='border: 0px')
img(src='http://sites.box.net/apps/web/simpleshare/img/logo.png')
View
17 lib/modules/vimeo.js → lib/modules/justintv.js
@@ -1,8 +1,8 @@
var oauthModule = require('./oauth')
, OAuth = require('oauth').OAuth;
-var vimeo = module.exports =
-oauthModule.submodule('vimeo')
+var justintv = module.exports =
+oauthModule.submodule('justintv')
.definit( function () {
this.oauth = new OAuth(
this.oauthHost() + this.requestTokenPath()
@@ -13,22 +13,21 @@ oauthModule.submodule('vimeo')
);
})
- .apiHost('http://vimeo.com/api/rest/v2')
- .oauthHost('http://vimeo.com')
+ .apiHost('http://api.justin.tv')
+ .oauthHost('http://api.justin.tv')
.requestTokenPath('/oauth/request_token')
.authorizePath('/oauth/authorize')
.accessTokenPath('/oauth/access_token')
- .entryPath('/auth/vimeo')
- .callbackPath('/auth/vimeo/callback')
+ .entryPath('/auth/justintv')
+ .callbackPath('/auth/justintv/callback')
.fetchOAuthUser( function (accessToken, accessTokenSecret, params) {
var promise = this.Promise();
- console.log(params, accessToken, accessTokenSecret);
- this.oauth.get(this.apiHost() + '?format=json&method=vimeo.people.getInfo&user_id=' + accessTokenSecret, accessToken, accessTokenSecret, function (err, data) {
+ this.oauth.get(this.apiHost() + '/api/account/whoami.json', accessToken, accessTokenSecret, function (err, data) {
if (err) return promise.fail(err);
- var oauthUser = JSON.parse(data.person);
+ var oauthUser = JSON.parse(data);
return promise.fulfill(oauthUser);
});
return promise;

0 comments on commit 9b49118

Please sign in to comment.
Something went wrong with that request. Please try again.