azure - Power BI 始终返回 403 Forbidden

标签 azure azure-active-directory powerbi

我正在尝试开发一个使用 Power BI API 的应用程序.

问题是,即使我有一个有效的身份验证 token ,到目前为止我尝试访问的每个 API 端点都会返回 403(禁止)Http 状态,响应正文中没有任何内容。

我认为我获得的 token 是有效的,因为当我第二天尝试使用相同的 token 时,它会给我一条“ token 过期消息”。

我使用的是法人 Azure Active Directory 帐户,但我不是管理员。但我可以完全访问 Power BI 工作区和报告 web interface .

我目前正在使用 Azure AD Oatuh2 v1 进行身份验证但我也尝试过v2没有成功(我仍在使用 v1,因为在 v2 上我不确定我的范围和资源参数是否正确)。

以下是我发送的请求:

GET
https://login.microsoftonline.com/{tenant}/oauth2/authorize?
client_id=<my client id>
&response_type=code
&redirect_uri=http%3A%2F%2Flocalhost%3A8080/azureLogin/authorize
&response_mode=query

localhost:8080/azureLogin/authorize 的重定向上获取授权码那么

POST https://login.microsoftonline.com/{tenant}/oauth2/token HTTP/1.1
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code
&client_id=<my client id>
&code=<the code I just got>
&redirect_uri=http%3A%2F%2Flocalhost%3A8080/azureLogin/authorize
&client_secret=<my client secret>

作为“租户”,我尝试了“common”和我的组织 ID。

但是当我尝试访问https://api.powerbi.com/v1.0/myorg/reports时与 Authorization: Bearer <token> header 。我收到 403 Forbiden 响应。

在 Azure AD 上,我可以看到我的用户已向我注册的此应用程序授予所有权限。

我错过了什么吗?我该如何解决这个问题?

最佳答案

为了让其他人看到答案,我总结了评论中分享的答案:

您错过了资源参数,您正在访问powerbi,所以应该是

resource: https://analysis.windows.net/powerbi/api

资源是目标 Web API(安全资源)的应用 ID URI。它也可能是外部资源,例如 https://graph.microsoft.com , https://analysis.windows.net/powerbi/api等等。这是授权或 token 请求之一所必需的。

关于azure - Power BI 始终返回 403 Forbidden,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57333660/

相关文章:

azure - 有没有办法循环 Azure DevOps 中 stageDependency 的所有输出?

azure-active-directory - AADSTS50013 : Assertion failed signature validation. [原因 - 未找到 key 。,客户端使用的 key 的指纹: 'xxxx'

excel - 简化 Power Query 中的 Text.Contains

number-formatting - Power BI - 数字格式

azure - 如何设置azure存储表的保留期限?

r - dbutils.fs.mount() 适用于 Python,但不适用于 R?

azure-active-directory - 基于 token 和基于 cookie 的应用程序之间的 SSO 体验

powerbi - 连接到所有列出站点的共享点列表和文档文件夹时,无法刷新 Power Bi 服务中的数据

azure - 使用 Azure 流分析保留最后的值

azure - 具有多个 Azure Web 应用程序的 SSO