我有一个angular应用程序,它使用passport-github2和oauth2来验证和访问github资源。我使用的是nodejs、koa和passport github,在github调用的回调中,我的服务器代码看起来有点像这样:
router.get('/auth/github/callback', function* (next) {
const ctx = this;
yield passport.authenticate('github', {
failureRedirect: '/login'
}, function* (err, profile, failed) {
if(!err && profile) {
const token = jwtHelper(profile);
ctx.redirect(config.client.syncUrl + '?token=' + token); 在angular的前端,我将执行如下操作来获取令牌:
const token = location.query.token我宁愿在响应头中发送令牌,但我不知道如何在前端角度代码中拉出头。
是否有可能以这种方式使用响应头?
发布于 2016-02-27 19:43:47
response.set(字段,值)
将响应报头字段设置为值:
this.set('Cache-Control', 'no-cache');因此,在您的情况下,应该是这样的:
ctx.set('Token', token)https://stackoverflow.com/questions/35595264
复制相似问题