【发布时间】:2019-08-02 21:30:41
【问题描述】:
我正在尝试开发一个使用 Power BI API 的应用程序。
问题是,即使我有一个有效的身份验证令牌,到目前为止我尝试访问的每个 API 端点都会返回一个 403(禁止访问)Http 状态,而响应正文中没有任何内容。
我认为我得到的令牌是有效的,因为当我第二天尝试使用相同的令牌时,它会给我一个“令牌过期消息”。
我正在使用我不是管理员的公司 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>
作为“租户”,我尝试了“普通”和我的组织 ID。
但是当我尝试使用Authorization: Bearer <token> 标头访问https://api.powerbi.com/v1.0/myorg/reports 时。我收到 403 Forbiden 响应。
在 Azure AD 上,我可以看到我的用户已授予我注册的此应用程序的所有权限。
我错过了什么吗?我该如何解决?
【问题讨论】:
-
我没有看到资源参数:
https://analysis.windows.net/powerbi/api所以不清楚你有一个有效的令牌for Power BI。 -
@DavidBrowne-Microsoft 成功了。非常感谢。你拯救了我的一天。但无法接受您的评论作为回复。
标签: azure azure-active-directory powerbi