reactjs - AcquireToken_In_Progress:登录调用期间出错 - 登录已在进行中
问题描述
我正在调用 microsoft graph api 也从 azure 门户获取用户,当时我无法获取用户而不是我需要用户列表,而且我正在获取登录 microsoft 的对话框。
const msalConfig = {
auth: {
clientId: "app-id",
redirectUri: `http://localhost:port`,
authority: "auth_url",
navigateToLoginRequestUrl: false,
},
cache: {
cacheLocation: "localStorage",
storeAuthStateInCookie: true,
},
};
const graphScopes = [
"User.ReadBasic.All",
"User.Read.All",
"User.ReadWrite.All",
"Directory.Read.All",
"Directory.AccessAsUser.All",
"Directory.ReadWrite.All",
];
const options = {
loginType: LoginType.Redirect,
tokenRefreshUri: window.location.origin + "/auth.html",
};
const msalApplication = new UserAgentApplication(msalConfig);
const scope = new MSALAuthenticationProviderOptions(graphScopes);
const authProvider = new ImplicitMSALAuthenticationProvider(msalApplication, scope);
const option = {
authProvider,
};
const client = Client.initWithMiddleware(option);
我正在使用这段代码来调用 api:
const getUser = async () => {
let list = [];
try {
list = await client.api(“https://graph.microsoft.com/beta/users?$count=true&$top=5”).header("ConsistencyLevel", "eventual").get();
} catch (error) {
throw error;
}
return list;
};
解决方案
推荐阅读
- php - 当网络刷新时,我的 HTML 表单中的数据消失了
- multithreading - 如何优雅地终止使用 queue.Queue 的多线程 Python 应用程序
- swift - Swift 协议使用另一个协议会导致错误
- android - logcat 显示错误我的应用程序不使用 SQLite 数据库在 gridview 上显示图像
- android - 检查引脚为假后如何从 GoodieBag Pinview 中删除输入?
- react-native - TypeError:无法读取未定义的属性“LENGTH_LONG”
- service-worker - 为什么注册 Service Worker 失败?
- python-ldap - python-ldap 库的 search_s search_ext_s search_s 方法不返回任何成功响应代码
- javascript - jQuery 忽略 HTTP 请求方法并附加奇怪的 URL 参数
- javascript - 如何将元素包装到创建的新元素