0

正在做

msalService.loginPopup();

进而:

$rootScope.$on("msal:loginSuccess", function () {
    console.log("loginSuccess");

    var token = msalService.userInfo.idToken;
});

我可以看到这userInfo.isAuthenticated是真的,并且存在一个 id 令牌。

但是,tokenReceivedCallback从不调用。

msalProvider.init({
    clientID: "Client ID here",
    authority: "https://login.microsoftonline.com/tfp/myb2caad.onmicrosoft.com/B2C_1_SignUpSignIn",
    validateAuthority: false,
    //consentScopes: ["https://myb2caad.onmicrosoft.com/test/user_impersonation"],
    tokenReceivedCallback: function (errorDesc, token, error, tokenType) {
        debugger;
        if (token) {
            console.log('Token type: ' + tokenType + ' Token: ' + token)
        }
        else {
            console.log(errorDesc + error)
        }
    }
},
    $httpProvider // Optionally, pass http provider to inject request interceptor to attach tokens
);

你能发现问题或给出一些提示在哪里寻找它吗?

4

1 回答 1

0

原来问题与hashPrefix. 该应用程序搞砸了。

我必须做:

app.config(['$locationProvider', function($locationProvider) {
    $locationProvider.html5Mode(false).hashPrefix('');
}]);

hashPrefix 干扰了回调。

这里提到:https ://www.npmjs.com/package/@azure/msal-angularjs

于 2019-07-09T20:58:05.380 回答