【发布时间】:2016-02-24 06:55:18
【问题描述】:
我有一个 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);
在有角度的前端,我将做这样的事情来获取令牌:
const token = location.query.token
我宁愿在响应标头中发送令牌,但我不知道如何在前端角度代码中拉出标头。
是否可以以这种方式使用响应标头?
【问题讨论】:
-
您如何为应用程序提供服务?你在用快递吗?
-
我正在使用koa,我在问题中提到过,如果不清楚,请见谅。
标签: angularjs node.js passport.js