0

Azure AD B2C 포털을 사용하여 토큰을 생성 중입니다. loginPopup 메서드를 사용할 때 tokenRedirect를 사용하는 동안 성공적으로 토큰을 생성 할 수 있지만 undefined을 얻었습니다. 여기 Azure AD B2C 포털에서 loginRedirect로 액세스 토큰 생성

코드입니다 :

clientApplication = new Msal.UserAgentApplication(
     this.tenantConfig.clientID, this.authority, 
     function (errorDesc: any, token: any, error: any, tokenType: any) { 
      // Called after loginRedirect or acquireTokenPopup 
     } 
); 

public login(): void { 
     var _this = this; 
     // loginRedirect loginPopup 
     this.clientApplication.loginPopup(this.tenantConfig.b2cScopes).then(function (idToken: any) { 
      _this.clientApplication.acquireTokenSilent(_this.tenantConfig.b2cScopes).then(
       function (accessToken: any) { 
        _this.access_token = accessToken; 
       }, function (error: any) { 
        _this.clientApplication.acquireTokenPopup(_this.tenantConfig.b2cScopes).then(
         function (accessToken: any) { 
          _this.access_token = accessToken; 
         }, function (error: any) { 
          bootbox.alert("Error acquiring the popup:\n" + error); 
         }); 
       }) 
     }, function (error: any) { 
      bootbox.alert("Error during login:\n" + error); 
     }); 
     console.log(`access token service file ${_this.access_token}`); 
    } 

날 내가 뭐하는 거지 실수 알려주세요? 범위 문제 또는 콜백 메소드 문제입니까?

답변

0

나는 reference을 찾았습니다. 이것으로 나는 액세스 토큰을 얻을 수 있었다. 당신은 sessionStorage.getItem('msal.idtoken')에 그것을 얻을 것이다.

+0

msal.nonce.idtoken에서이 파일을 발견했습니다. –

-1

loginRedirect의 경우 처리기 코드를 // Called after loginRedirect or acquireTokenPopup 블록에 추가합니다.

clientApplication = new Msal.UserAgentApplication(
     this.tenantConfig.clientID, this.authority, 
     function (errorDesc: any, token: any, error: any, tokenType: any) { 
      // Called after loginRedirect or acquireTokenPopup 
      // perform your logic HERE! :) 
     } 
); 

public login(){ 
    this.clientApplication.loginRedirect(this.tenantConfig.b2cScopes); 
} 
+0

위의 내용은 Angular 4 응용 프로그램에서 loginredirect 후에 호출되지 않습니다. –

+0

@ShailenSukul 그것은 나를 위해! 이 샘플 앱 [NetCoreAngularAzureB2CMsal] (https://github.com/spottedmahn/NetCoreAngularAzureB2CMsal/blob/master/ClientApp/app/services/authentication.service.ts)을 참조하십시오. – spottedmahn