OhAuth是基于Node.js的扩展,用于简化OAuth的开发,实现客户端无重定向的OAuth认证支持。
示例代码:
varExpress=require('express'),app=Express.createServer(Express.favico(),Express.static(__dirame)),OhAuth=require('./ohauth'),strategies=require('./ohauth-strategies');varcK='cosumerKey',cS='cosumerSecret',ohAuth=ewOhAuth(strategies.twitter(cK,cS,'https://127.0.0.1:1337'),app);app.cofigure(fuctio(){app.use(app.router);});app.liste(1337);app.get('/',fuctio(req,res){res.sedfile(__dirame+'/idex.html');});//wheyou'redoe,you'llgetaaccesskeyadaaccesssecretpritigouthereapp.get('/oauth/success',fuctio(req,res){res.sed(req.sessio.credetials);});
评论