我试图使用护照向RTC进行身份验证。我的代码如下:
*var config = require('./public/scripts/oauthconfig.js')
var passport = require('passport');
var https = require('https');
var OAuthStrategy = require('passport-oauth').OAuthStrategy;
var cookieParser = require('cookie-parser');
var cookieSession = require('cookie-session');
passport.use('jazz', new OAuthStrategy({
requestTokenURL: config.rtc.requestTokenURL,
accessTokenURL: config.rtc.accessTokenURL,
userAuthorizationURL: config.rtc.userAuthorizationURL,
consumerKey: config.rtc.consumerKey,
consumerSecret: config.rtc.consumerSecret,
callbackURL: config.rtc.callbackURL
},
function(token, tokenSecret, profile, done) {
return done(null, profile);
}
));
passport.serializeUser(function(user, done) {
console.log('serializeUser: ' + user._id)
done(null, user._id);
});
console.log("Starting in Test Mode:4");
passport.deserializeUser(function(id, done) {
done(null, id);
});
app.use(cookieParser());
app.use(cookieSession({ secret: 'secret', cookie: { maxAge: new Date(Date.now() + 3600000), }}));
app.use(passport.initialize());
app.use(passport.session({"secret":"secret"}));
app.get('/', function(request, response) {
response.render('index', {
user: request.user
});
});
app.get('/auth/jazz', passport.authenticate('jazz'));
app.get('/auth/jazz/callback',
passport.authenticate('jazz', {successRedirect: '/', failureRedirect: '/auth/jazz' }));
The config is specified as below:
var cfg = {
rtc: {
requestTokenURL: '[rtc_server]:9443/jts/oauth-request-token',
accessTokenURL: '[rtc_server]:9443/jts/oauth-access-token',
userAuthorizationURL: '[rtc_server]:9443/jts/oauth-authorize',
consumerKey: '5818a222233333333344444444472c62c5',
consumerSecret: 'secret',
callbackURL: '[rtc_server]:9443/auth/jazz/callback',
host: '[rtc_server]',
port: '9443'
}
}*
现在当我在/ auth / jazz上调用xhrGet时,我希望浏览器使用consumerKey和secret进行身份验证。但等待超过1分钟后请求超时..
由于我是新手,我无法弄清楚实际问题。我也在日志中收到此消息:
错误的InternalOAuthError:无法获取请求令牌 错误在emitErrorNT(net.js:1256:8) 错误的OAuthStrategy._createOAuthError(/ home / vcap / app / node_modules / passport- oauth / node_modules / passport-oauth1 / lib / strategy.js:396:17)
错误/home/vcap/app/node_modules/passport-oauth/node_modules/passport-oauth1/node_modules/oauth/lib/oauth.js:543:17
在ClientRequest上犯了错误。 (/home/vcap/app/node_modules/passport-oauth/node_modules/passport-oauth1/node_modules/oauth/lib/oauth.js:421:9)