在离子4中对MSAdal进行身份验证后,redirectUrl是什么?

时间:2018-12-05 04:51:51

标签: angular azure ionic-framework cordova-plugins adal

成功验证用户身份后,我要将其重定向到应用程序根页面。 authContext.acquireTokenAsync的redirectUrl是什么?

      let authContext: AuthenticationContext = this.msAdal.createAuthenticationContext('https://login.windows.net/common');
  authContext.acquireTokenAsync('https://graph.windows.net', this.clientId, 'http://localhost:8100/')
    .then((authResponse: AuthenticationResult) => {
      alert('Token is' + authResponse.accessToken);
      alert('Token will expire on' + authResponse.expiresOn);
      this.statusBar.styleDefault();
      this.splashScreen.hide();
      this.nav.setRoot(HomePage);
    })
    .catch((e: any) => {
      alert('Authentication failed'+ e);
      this.nav.setRoot(HomePage);
    });

1 个答案:

答案 0 :(得分:1)

问题是该应用程序已在Azure活动目录上注册为WebApp。我已经在活动目录中将新应用注册为本机应用。带有重定向网址“ urn:ietf:wg:oauth:2.0:oob”,并且现在可以正常使用。这是我的代码

    let authContext: AuthenticationContext = this.msAdal.createAuthenticationContext('https://login.windows.net/common');
authContext.acquireTokenAsync('https://graph.windows.net','<Your Native App client ID>' , 'urn:ietf:wg:oauth:2.0:oob', '', null)
  .then((authResponse: AuthenticationResult) => {
    this.presentToast('Token is' + authResponse.accessToken + ' and expires on ' + authResponse.expiresOn);
    this.statusBar.styleDefault();
    this.splashScreen.hide();
    this.nav.setRoot(HomePage);
  })
  .catch((e: any) => {
    this.presentToast('Authentication failed ' + e)
  })
相关问题