Angular4-无效的承载令牌,令牌= null

时间:2018-10-05 11:07:27

标签: angular

我在用Angular4编写的应用程序中遇到此错误,但是我无法弄清楚这是什么意思。

这是堆比赛:

content.js:92 invalid bearer token, token= null
_callee3$ @ content.js:92
tryCatch @ runtime.js:62
invoke @ runtime.js:296
prototype.(anonymous function) @ runtime.js:114
step @ content.js:218
(anonymous) @ content.js:218
Promise.then (async)
step @ content.js:218
(anonymous) @ content.js:218
(anonymous) @ content.js:218
run @ content.js:171
(anonymous) @ content.js:357
EventImpl.dispatchToListener @ VM3027 extensions::event_bindings:403
publicClassPrototype.(anonymous function) @ VM3033 extensions::utils:138
EventImpl.dispatch_ @ VM3027 extensions::event_bindings:387
EventImpl.dispatch @ VM3027 extensions::event_bindings:409
publicClassPrototype.(anonymous function) @ VM3033 extensions::utils:138
messageListener @ VM3036 extensions::messaging:240
EventImpl.dispatchToListener @ VM3027 extensions::event_bindings:403
publicClassPrototype.(anonymous function) @ VM3033 extensions::utils:138
EventImpl.dispatch_ @ VM3027 extensions::event_bindings:387
EventImpl.dispatch @ VM3027 extensions::event_bindings:409
publicClassPrototype.(anonymous function) @ VM3033 extensions::utils:138
dispatchOnMessage @ VM3036 extensions::messaging:392

这是content.js第92行的专家:

case 7:
isLogged = _context3.sent;
if (!isLogged.valid) {
  console.error('invalid bearer token, token=', localStorage.getItem('token'));
  changeIcon('unavailable');
} else {
  if (!isLogged.customerId) {
    changeIcon('unavailable');
  } else if (!isLogged.invitation) {
    changeIcon('uninvited');
  } else if (!isLogged.plan || !isLogged.plan.active) {
    changeIcon('unavailable');
  }
}
_context3.next = 15;
break;

该应用程序可以正常运行,但是我在控制台中充满了这些错误。

1 个答案:

答案 0 :(得分:1)

 invalid bearer token, token= null

这意味着令牌中的某个逻辑没有被保存到localStorage中。

  • 检查服务器是否正在返回令牌。
  • 检查Web应用程序是否正确接收和存储令牌。
  • 检查启动身份验证过程的逻辑是否正确。