Angular 8获取令牌失败{“ _error”:“令牌更新操作由于超时而失败”,“ _ errorDesc”:“令牌更新失败”,“ _ scopes”:“”}

时间:2019-11-21 22:52:33

标签: angular msal

当请求使用msal-angular的访问令牌时,出现以下错误并增加了loadFrameTimeout时间,但仍然无法获取令牌

ngOnInit() {
    console.log("inicia");

    this.getUSerProfile();

    this.subscription = this.broadcastService.subscribe("msal:acquireTokenSuccess", (payload) => {
      console.log("acquire token success " + JSON.stringify(payload));
    });

    //will work for acquireTokenSilent and acquireTokenPopup
    this.subscription = this.broadcastService.subscribe("msal:acquireTokenFailure", (payload) => {

      console.log("acquire token failure " + JSON.stringify(payload))
     //if (payload.errorCode == "consent_required" || payload.errorCode == "interaction_required" || payload.errorCode == "login_required") {
      if (payload.errorDesc.indexOf("consent_required") !== -1 || payload.errorDesc.indexOf("interaction_required") != -1 ) {  
     this.authService.acquireTokenPopup(["XXXXXX-cdd8-4c6a-b0c5-XXXXXXXX/user_api"]).then((token) => {
          this.getUSerProfile();
        }, (error) => {
        });
      }
    });
  }

0 个答案:

没有答案