首页 > 解决方案 > Ionic __Azure AD 身份验证错误:用户取消了流程

问题描述

我在 ionic 3。我想获取访问令牌以调用其余 API。这是我的仓库https://my-app.visualstudio.com/_apis/projects?api-version=2.0 和 Ionic 配置文件在这里。但是运行此代码后我收到一条错误消息。

    //Here is code
    let authContext: AuthenticationContext = this.msAdal.createAuthenticationContext('https://login.windows.net/tenant-id');

    authContext.acquireTokenAsync(
        'https://my-app.visualstudio.com/_apis/projects?api-version=2.0',
        'app_id',
        window.location.origin + '/',
        'email',
        null
    )
        .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));
}

错误信息

'Authentication failed Error: User cancelled the flow RequestId:679502144 CorrelationId: 9b553979-94a5-482e-b9f8-a91aba56108a
    at fail (CordovaBridge.js:37)
    at Object.callbackFromNative (cordova.js:293)
    at <anonymous>:1:9'}

标签: javascriptc#asp.netionic3adal

解决方案


推荐阅读