【发布时间】:2020-08-20 12:01:22
【问题描述】:
我正在尝试使用 Power BI (Power Query) 访问使用 Windows 身份验证并需要 api 密钥标头的不记名令牌 API。我遇到的问题是 Power BI 只接受某些标头。当我尝试包含我的组织的“api-key”标头时,我收到以下错误消息:
Expression.Error: The 'api-key' header is only supported when connecting anonymously. These headers can be used with all authentication types: Accept, Accept-Charset, Accept-Encoding, Accept-Language, Cache-Control, Content-Type, If-Modified-Since, Prefer, Range, Referer
我使用的代码看起来像这样,虽然我尝试了几种变体:
let
securityTokenServiceUrl = "https://mysecurityservice",
myApiKey = "123456789",
securityHeader = "{
""accept"": ""text/plain"",
""api-key"": """& myApiKey & """
}",
tokenResponse = Json.Document(Web.Contents(securityTokenServiceUrl, [
Headers = Json.Document(securityHeader)
])),
token = tokenResponse[access_token]
in
token
我已经做了很多环顾四周,但只能找到有关如何使用匿名授权而不是 Windows Auth 执行此操作的建议,因为我需要。我尝试按照here 的建议使用自定义数据连接器,但似乎无法正常工作。有什么办法可以绕过这个限制并如上所述传递我的 api 密钥头?
【问题讨论】:
-
嗨@RobC,又是我 :) 你的链接“mysecurityservice”起来了吗?我收到错误 - DataSource.Error:无法解析远程名称:'mysecurityservice'
-
不,这不是一个真实的 URL。真正的一个是我工作的内部。对困惑感到抱歉。我开始认为,出于某种原因,Power BI 只是不允许将自定义标头用于 Windows 身份验证。我在任何地方都没有看到任何证据。
标签: powerbi powerquery powerbi-desktop