簡體   English   中英

在瀏覽器中生成范圍為 Kusto Azure 數據資源管理器的訪問令牌

[英]Generate an access token in the browser that is scoped to Kusto Azure Data Explorer

從命令行我可以使用以下命令生成訪問令牌:

az account get-access-token

但是,此訪問令牌不適用於kusto ,因為該令牌尚未確定范圍。

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

這提供了一個被kusto接受的訪問令牌。

我的問題與@azure/msal-browser庫有關,以及我如何 scope 訪問令牌特定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庫相關的其他答案,但它們沒有幫助。 任何幫助,將不勝感激!

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

嘗試刪除.default

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM