Passport strategy for authenticating with Odesk using the OAuth 1.0a API.
This module lets you authenticate using Odesk in your Node.js applications. By plugging into Passport, Odesk authentication can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.
$ npm install passport-odesk
We need to get this keyes from Odesk api. For example, I used this values:
passport.use(new OdeskStrategy({
consumerKey: 'f448b92c4aaf8918c0106bd164a1656',
consumerSecret: 'e6a71b4f05467054',
callbackURL: "http://127.0.0.1:3000/auth/odesk/callback"
},
function(token, tokenSecret, profile, done) {
User.findOrCreate({ id: profile.id }, function (err, user) {
return done(err, user);
});
}
));
Use passport.authenticate()
, specifying the 'odesk'
strategy, to
authenticate requests.
For example, as route middleware in an Express application:
app.get('/auth/odesk',
passport.authenticate('odesk'));
app.get('/auth/odesk/callback',
passport.authenticate('odesk', { failureRedirect: '/login' }),
function(req, res) {
// Successful authentication, redirect home.
res.redirect('/');
});
For a complete, working example, refer to the signin example.
{
provider: 'odesk',
id: 'John_Doe',
name: { familyName: 'Doe', givenName: 'John' },
ref: '3603850',
displayName: 'John Doe',
img: 'https://odesk-prod-portraits.s3.amazonaws.com/Users:johnDoe:PortraitUrl_50?AWSAccessKeyId=1XVAX3FNQZAFC9GJCFR2&Expires=2147483647&Signature=P7XYYyZr9c%2Bvv%2F25voKeTg92eFc%3D',
country: 'Russia',
profile: 'https://www.odesk.com/users/~johnDoe',
emails: [ { value: 'JohnDoe@odesk.com', type: 'work' } ],
timezone: 'Europe/Klin',
timezone_offset: '14400',
location: { city: 'Klin', state: '', country: 'Russia' },
company_url: 'http://example.com'
}
Install vows first
$ npm install vows
$ npm test
Copyright (c) 2011-2013 Ostroumov Anatolij <http://teksi.ru/resume/>
Based on Plugin <https://github.com/jaredhanson/passport-twitter> by Jared Hanson <http://jaredhanson.net/>