azure-active-directory - Azure HTTP POST 请求来自 Power BI 的访问令牌
问题描述
是否可以通过 HTTP POST 请求从 Power BI 电源查询中获取 Azure AD 应用程序访问令牌?
HTTP POST 请求:
//request url
https://login.microsoftonline.com/<tenant id>/oauth2/token
//header
Content-Type: application/x-www-form-urlencoded
//request body
grant_type=client_credentials
client_id=625bc9f6xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
client_secret=bCBxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
resource=api://xxxxxxxxxxxxxxxxxxxxxxxxxxx
好的,它看起来很简单,它可以很好地与Postman
orpython
请求配合使用,并显示带有 json 数据的成功响应。Power BI power query
现在我的问题是我想通过这个请求power query
let
apiUrl = "https://login.microsoftonline.com/<tenant id>/oauth2/token",
body = "{
""grant_type"": ""client_credentials"",
""client_id"": ""625bc9f6xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"",
""client_secret"": ""bCBxxxxxxxxxxxxxxxxxxxxxxxxxxx"",
""resource"": ""api://xxxxxxxxxxxxxxxxxxxxxxxxxxx""
}",
Source = Web.Contents(apiUrl, [Headers=[#"Content-Type"="application/x-www-form-urlencoded"],
Content=Text.ToBinary(body)]),
FormatAsJson = Json.Document(Source)
in
FormatAsJson
但它说错误的请求
DataSource.Error: Web.Contents failed to get contents from
'https://login.microsoftonline.com/61ed5503-xxxxxxxxxxxxxxxxx/oauth2/token' (400): Bad Request
我错过了什么或为什么它说错误的请求?是不是它的原因REST API
?还是有其他方法可以完成它?
解决方案
我解决了,实际上我必须添加一些额外的术语,而且我自己也犯了一个愚蠢的错误,正确的查询
let
apiUrl = "https://login.windows.net/61xxxxxxxxxxxx/oauth2/token",
body = [
client_id="3728xxxxxxxxxxxxxx5",
grant_type="client_credentials",
client_secret="bxxxxxxxxxxxxh",
resource="api://xxxxxxxxxxxxxxxx5"
],
Source = Json.Document(Web.Contents(apiUrl, [Headers = [Accept = "application/json"],
Content = Text.ToBinary(Uri.BuildQueryString(body))]))
in
Source
推荐阅读
- firebase - 可以将 userData 写入 Firebase,无法从 Firebase 读取到字段:Flutter
- c++ - 使用源文件中的宏生成二进制文件
- reactjs - 全局导入 react 而不是在每个组件中导入 [React Hooks]
- javascript - Bootstrap 折叠响应式导航栏在小屏幕上打开后关闭
- python - 为特定频道发送持续消息 discord.py
- r - 在 R 中中断对(SQLite)数据库的 dbplyr 查询
- java - eXist-db 查询:文件:移动返回错误
- python - python - 从文件读取时,json不断返回JSONDecodeError
- teradatasql - 使用 CASE 语句和“+”添加多个列,但功能添加不正确
- sql - 如何获取每种类型过去 x 周的数据?