oauth - 使用现有 AAD 令牌为 Kusto 请求令牌
问题描述
我正在尝试让用户登录到我的机器人(Microsoft 机器人框架)并进行 Kusto 查询。我已成功获得 Graph JWT,但我不知道如何请求 Kusto 访问权限。
AuthenticationContext authContext = new AuthenticationContext("https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-*********");
var clientAppID = "974c5166-f8b5-466e-9552-*********";
var secret = "[*SxczFa7qU*******************";
var tokenForKusto = await authContext.AcquireTokenAsync(
"https://aznw.kusto.windows.net",
new ClientCredential(clientAppID, secret),
new UserAssertion(userToken));
我希望tokenForKusto
是一个有效的令牌,但它会引发异常。
{"AADSTS500131: Assertion audience does not match the Client app presenting the assertion. The audience in the assertion was '00000002-0000-0000-c000-000000000000' and the expected audience is '974c5166-f8b5-466e-9552-********' or one of the Application Uris of this application with App ID '974c5166-f8b5-466e-9552-********'(testbotbuilderAAD).\r\nTrace ID: 38515779-b858-4efc-8b03-e9f8ec810c00\r\nCorrelation ID: a136600d-66e0-44fc-8f24-d1fda6b4ba56\r\nTimestamp: 2019-07-19 17:23:27Z"}
解决方案
这是因为您尝试使用为 Graph 颁发的令牌,但您的应用程序不是 Graph。仅当且仅当客户端应用程序 ID(来自 ClientCredentials)与您尝试使用的令牌的受众匹配时,此流程才有效。
无论如何,您为什么要检索 Graph 的令牌?如果要发出 Kusto 查询,则应使用集群 URI 作为资源(例如,“ https://cluster.region.kusto.windows.net ”)
推荐阅读
- python - 使用 google 样式的文档字符串键入注释
- bash - 将命令结果存储在变量更改结果中
- sql - 可编辑表的数据库设计
- apache - 我的 .htaccess 文件中存在与 SEO 友好 URL 相关的问题
- python - 在数据框中搜索数字时,它显示:“numpy.int64”类型的参数不可迭代。如何解决?
- python - Python numpy 2D数组对某些索引求和
- javascript - 如何删除画布上两个透明形状的交集?
- python - 在 Python 中,当您可以采用默认参数时,为什么要使用“val = param 或 None”?
- android - admob_flutter 包是否支持中介?
- python - 如何改进 CNN 模型达到损失平台期?