Примечание: работает на некоторых машинах. Какие-либо настройки, которые нам не хватает?
Перенаправление входа просто запрашивает имя пользователя и не отображает окно пароля, и оно загружается навсегда. Мы используем Microsoft.Toolkit.Wpf.UI.Controls.webview внутри окна инструмента визуальной студии (UserControl.xaml).
Код MSAL выглядит так ниже,
//First login redirect request
private onSignIn = async (redirect?: any) => {
if (redirect) {
return msalApp.loginRedirect(GRAPH_REQUESTS.LOGIN);
}
}
//ComponentDidMount it hits after redirect successful and it get account details
public async componentDidMount(): Promise<void> {
const account = msalApp.getAccount();
if (account) {
const tokenResponse = await this.acquireToken(
GRAPH_REQUESTS.XXX,
);
if (tokenResponse) {
localStorage.setItem('access_token', tokenResponse.accessToken);
}
}
//Request for acquireTokensilent
private acquireToken = async (request: any) => {
return msalApp.acquireTokenSilent(request);
}
Настройки MSAL выглядят так, как показано ниже,
export const msalApp = new UserAgentApplication({
auth: {
clientId: "XXXXX",
authority: "https://login.microsoftonline.com/common",
redirectUri: "XXXX",
validateAuthority: true,
postLogoutRedirectUri: "XXXX",
navigateToLoginRequestUrl: false
},
cache: {
cacheLocation: "sessionStorage",
storeAuthStateInCookie: isIE()
},
system: {
navigateFrameWait: 0,
}
});
export const isIE = () => {
const ua = window.navigator.userAgent;
const msie = ua.indexOf("MSIE ") > -1;
const msie11 = ua.indexOf("Trident/") > -1;
// If you as a developer are testing using Edge InPrivate mode, please add "isEdge" to the if check
// const isEdge = ua.indexOf("Edge/") > -1;
return msie || msie11;
};
Странно, что на одних машинах он работает, а на других - нет. Веб-просмотр создает проблему? или есть проблемы с настройками MSAL?