在命令行中,我可以使用以下命令生成访问令牌:
az account get-access-token
但是,该访问令牌不能与kusto一起工作,因为该令牌还没有确定作用域。
az account get-access-token --resource https://{name}.{location}.kusto.windows.net
这提供了kusto接受的访问令牌。
我的问题与@azure/msal-browser库有关,以及如何将访问令牌限定为特定的resource。在下面的示例中,我使用的是@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库相关的其他答案,但它们都没有帮助。任何帮助都将不胜感激!
发布于 2021-07-18 15:00:01
看起来目前使用的是https://{name}.{location}.kusto.windows.net/.default
尝试删除.default
https://stackoverflow.com/questions/67896084
复制相似问题