我正在尝试在ionic 5中实现Microsoft SSO身份验证。
当执行下面的代码时,控制台中会发生取消定义。问题出在哪部分?
login(){
let authContext: AuthenticationContext = this.msAdal.createAuthenticationContext('https://login.windows.net/common');
authContext.acquireTokenAsync('https://graph.windows.net', 'clientID', 'http://localhost:8200')
.then((authResponse: AuthenticationResult) => {
console.log('Token is' , authResponse.accessToken);
console.log('Token will expire on', authResponse.expiresOn);
})
.catch((e: any) => console.log('Authentication failed', e));}
错误=>

发布于 2021-07-15 13:44:13
const browser = this_.iab.create("https://login.microsoftonline.com/" + tenant_id +
"/oauth2/authorize?response_type=id_token&client_id=" + client_id
+"&state=SomeState&nonce=SomeNonce"
, '_blank', 'clearsessioncache=yes,clearcache=yes,toolbar=no,location=no,toolbarposition=top,hidenavigationbuttons=yes,toolbarcolor=#0072bb')
browser.on("loadstart").subscribe(event => {IAB在应用程序浏览器中。当我们需要对azure AD b2c进行这种类型的身份验证时,我们也曾尝试使用Msal。同样,你也必须为你的案例做些什么。
有企业级插件可用,其成本约为8lakhs INR。
这就是我们要做的。租户id和客户端id,当您在azure帐户中的应用程序下注册您的应用程序时,您将获得。
因此,一旦登录成功,load listener将监听IAB正在访问的页面。如果发现出现#token_id(在完全登录后)。
iab将自动关闭,ionic应用程序页面将恢复,或者您可以在该事件侦听器中添加一些新的路由条目。
对于您的情况,基本url可能会更改。因此,首先尝试使用打开案例登录的url访问chrome。并相应地改变。
使用IAB而非MSAL使IT正常工作
https://stackoverflow.com/questions/68386865
复制相似问题