gpt4 book ai didi

reactjs - 在范围为 Kusto Azure 数据资源管理器的浏览器中生成访问 token

转载 作者:行者123 更新时间:2023-12-03 00:21:37 25 4
gpt4 key购买 nike

从命令行我可以使用以下命令生成访问 token :

az 帐户获取访问 token

但是,此访问 token 无法与 kusto 一起使用,因为该 token 尚未确定作用域。

az account get-access-token --resource https://{name}.{location}.kusto.windows.net

这提供了 kusto 接受的访问 token 。

我的问题涉及 @azure/msal-browser 库以及如何将访问 token 限定为特定资源。在下面的示例中,我使用 @azure/msal-react,它只是底层 @azure/msal-browser 库之上的抽象层。

import { useMsal, useAccount } from '@azure/msal-react';

const ControllerRequester = () => {
const { accounts, instance } = useMsal();
const account = useAccount(accounts[0] || {});

if (Object.keys(accounts).length) {
instance.acquireSilentToken({
account,
// What other properties do I need to include to scope the access token to kusto
}).then(accessToken => doSomething(accessToken))
}

return <div>...</div>

}

我尝试了一些不同的选项,例如 scopes: ['https://{name}.{location}.kusto.windows.net/.default'] 但没有太多成功。我还阅读了与 msal 库相关的其他答案,但它们没有帮助。任何帮助将不胜感激!

最佳答案

看起来目前使用的是 https://{name}.{location}.kusto.windows.net/.default

尝试删除 .default

关于reactjs - 在范围为 Kusto Azure 数据资源管理器的浏览器中生成访问 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67896084/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com