我想找一个简单的adal。使用基本asp运行的js示例。net核心mvc项目(无授权属性)。当我在下面运行时,我会按预期重定向到AAD,我单击我的用户,然后很快重定向回我的页面,然后返回到AAD登录对话框。我得到一个“需要用户登录”。你知道我做错了什么吗?
var variables = {
// Domain of Azure AD tenant
azureAD: "xx.onmicrosoft.com",
// ClientId of Azure AD application principal
clientId: "xx-xx-xx-xx"
}
window.config = {
tenant: variables.azureAD,
clientId: variables.clientId,
postLogoutRedirectUri: window.location.origin,
cacheLocation: "localStorage",
endpoints: {
graphApiUri: "https://graph.microsoft.com"
},
};
var authContext = new AuthenticationContext(config);
var user = authContext.getCachedUser();
if (!user) {
authContext.login();
}
authContext.acquireToken(config.endpoints.graphApiUri, function (error, token) {
if (error || !token) {
console.log("ADAL error occurred: " + error);
return;
}
else {
}
});