在 ionic 4 中对 MSADal 进行身份验证后的 redirectUrl 是什么?
What will be the redirectUrl after authentication for MSAdal in ionic 4?
当用户通过身份验证成功后,我想将其重定向到应用程序根页面。 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);
});
问题是该应用程序在 Azure Active Directory 上注册为 WebApp。我已经在活动目录上注册了一个新应用程序作为本机应用程序。使用 redirect url "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)
})
当用户通过身份验证成功后,我想将其重定向到应用程序根页面。 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);
});
问题是该应用程序在 Azure Active Directory 上注册为 WebApp。我已经在活动目录上注册了一个新应用程序作为本机应用程序。使用 redirect url "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)
})