Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #24 from slickplaid/vimeo

Vimeo OAuth Module
  • Loading branch information...
commit 02a457e83ea9180c5dbfee5b8e944f30f1879e31 2 parents 76b02c6 + 085b121
@bnoguchi authored
View
58 README.md
@@ -15,6 +15,7 @@ So far, `everyauth` enables you to login via:
- `readability`                             (Credits [Alfred Nerstu](https://github.com/alfrednerstu))
- `dropbox`                                    (Credits [Torgeir](https://github.com/torgeir))
- `justin.tv`                                 (Credits [slickplaid](https://github.com/slickplaid))
+ - `vimeo`                                 (Credits [slickplaid](https://github.com/slickplaid))
- OAuth2
- `facebook`
- `github`
@@ -1017,6 +1018,62 @@ To see all parameters that are configurable, the following will return an object
everyauth.justintv.configurable();
```
+## Setting up Vimeo OAuth
+
+You will first need to sign up for a [developer application](http://vimeo.com/api/applications) to get the consumer key and secret.
+
+```javascript
+var everyauth = require('everyauth')
+ , connect = require('connect');
+
+everyauth.vimeo
+ .consumerKey('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 usersByVimeoId[user.id] || (usersByVimeoId[user.id] = 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);
+```
+
+You can also configure more parameters (most are set to defaults) via
+the same chainable API:
+
+```javascript
+everyauth.vimeo
+ .entryPath('/auth/vimeo')
+ .callbackPath('/auth/vimeo/callback');
+```
+
+If you want to see what the current value of a
+configured parameter is, you can do so via:
+
+```javascript
+everyauth.vimeo.callbackPath(); // '/auth/vimeo/callback'
+everyauth.vimeo.entryPath(); // '/auth/vimeo'
+```
+
+To see all parameters that are configurable, the following will return an
+object whose parameter name keys map to description values:
+
+```javascript
+everyauth.vimeo.configurable();
+```
+
## 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/
@@ -1488,6 +1545,7 @@ Thanks to the following contributors for the following modules:
- DropBox
- [slickplaid](https://github.com/slickplaid)
- Justin.tv
+ - Vimeo
### MIT License
Copyright (c) 2011 by Brian Noguchi
View
4 example/conf.js
@@ -43,6 +43,10 @@ module.exports = {
consumerKey: 'uhfqnbely5stdtm'
, consumerSecret: 'jr7ofuwo32l7vkd'
}
+ , vimeo: {
+ consumerKey: 'Enter your consumer key here'
+ , consumerSecret: 'Enter your consumer secret here'
+ }
, box: {
apiKey: '5hl66lbfy0quj8qhhzcn57dflb55y4rg'
}
View
10 example/server.js
@@ -4,6 +4,7 @@ var express = require('express')
everyauth.debug = true;
+var usersByVimeoId = {};
var usersByJustintvId = {};
var usersByDropboxId = {};
var usersByFbId = {};
@@ -205,6 +206,15 @@ everyauth
})
.redirectPath('/')
+everyauth.vimeo
+ .consumerKey(conf.vimeo.consumerKey)
+ .consumerSecret(conf.vimeo.consumerSecret)
+ .findOrCreateUser( function (sess, accessToken, accessSecret, vimeoUser) {
+ return usersByVimeoId[vimeoUser.id] ||
+ (usersByVimeoId[vimeoUser.id] = vimeoUser);
+ })
+ .redirectPath('/')
+
everyauth.justintv
.consumerKey(conf.justintv.consumerKey)
.consumerSecret(conf.justintv.consumerSecret)
View
8 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')
#justintv-login
a(href='/auth/justintv', style='border: 0px')
img(src='http://s.jtvnw.net/jtv_user_pictures/hosted_images/new_logo_148_40_black.png')
@@ -84,7 +87,10 @@
p= JSON.stringify(everyauth.dropbox.user)
- if (everyauth.justintv)
h3 Justin.tv User Data
- p= JSON.stringify(everyauth.justintv.user)
+ p= JSON.stringify(everyauth.justintv.user)
+ - if (everyauth.vimeo)
+ h3 Vimeo User Data
+ p= JSON.stringify(everyauth.vimeo.user)
- if (everyauth.box)
h3 Box.net User Data
p= JSON.stringify(everyauth.box.user)
View
20 lib/modules/vimeo.js
@@ -0,0 +1,20 @@
+var oauthModule = require('./oauth');
+
+var vimeo = module.exports =
+oauthModule.submodule('vimeo')
+
+ .apiHost('http://vimeo.com/api/rest/v2')
+ .oauthHost('http://vimeo.com')
+
+ .entryPath('/auth/vimeo')
+ .callbackPath('/auth/vimeo/callback')
+
+ .fetchOAuthUser( function (accessToken, accessTokenSecret, params) {
+ var promise = this.Promise();
+ this.oauth.get(this.apiHost() + '?format=json&method=vimeo.people.getInfo&user_id=' + accessTokenSecret, accessToken, accessTokenSecret, function (err, data) {
+ if (err) return promise.fail(err);
+ var oauthUser = JSON.parse(data);
+ return promise.fulfill(oauthUser.person);
+ });
+ return promise;
+ });
Please sign in to comment.
Something went wrong with that request. Please try again.