【发布时间】:2019-06-03 03:27:30
【问题描述】:
我使用了护照推特策略,碰巧在我执行策略时我无法在客户端看到护照登录窗口
这就是我最初正在做的事情
class Auth extends ParentClass {
constructor(context, options) {
super()
this.app.get('/callback/:service', (req, res) =>
this.callbackEndpoint(req,res))
this.app.get('/', (req, res, next) => this.loginEndpoint(req, res, next))
}
async loginEndpoint (req, res, next) {
if (req.query.Twitter) {
console.log(`Inside Twitter Authentication`)
passport.authenticate('twitter', { scope : ['email'] })(req,res,next);
}
}
在我的 ParentClass 中,我或多或少地初始化了一些东西
class ParentClass {
this.use(corsMiddleware(options.CORS_URLS))
this.use(bodyParser.json())
this.use(session({
secret: 'keyboard cat',
resave: false,
saveUninitialized: true,
cookie: { secure: true }
}))
this.use(passport.initialize())
this.use((passport.session()))
}
use (middleware) {
this.app.use(middleware)
}
}
最后,这是我的护照策略
passport.use(new TwitterStrategy({
consumerKey: functions.config().twitterCredentials.apikey,
consumerSecret: functions.config().twitterCredentials.apiSecretKey,
callbackURL: redirect_uri,
passReqToCallback: true
}, async (req, accessToken, refreshToken, params, profile, done) => {
console.log(`logging from Passport Twitter ${req.workspace, req.accessToken}`)
done()
}))
从第一个代码中,sn-p 我看到了日志Inside Twitter Authentication,但此后没有任何反应。
我期待什么?显示一个窗口让我登录推特,但什么也没有显示,过了一段时间我在控制台信息中得到了这个:Execution took 569847 ms, finished with status: 'timeout'
以下是我的问题: 1.我们可以使用谷歌功能的护照和正常的oauth流程吗? (如果没有回答就评论) 2. 如果是的话,我们可以在我上面的代码中发现错误吗?
更新说明:在谷歌搜索我的问题时,我偶然发现了这个老问题,并意识到虽然它有点相似,但对前一个问题的描述非常模糊。我今天晚些时候问了一个类似的问题,但决定将它与这个问题合并。
【问题讨论】:
标签: node.js firebase express google-cloud-functions passport.js