访问Power BI API时获取401 Unauthorized

问题描述 投票:0回答:2

这是Postman中API调用的屏幕截图。我正在获取令牌并在此处使用它。

enter image description here

我得到401 Unauthoized没有回应。是因为应用注册中的权限?

我拥有Power BI Service和Windows Azure Active Directory的以下权限:enter image description here enter image description here

但是,当我点击授予权限时,我收到错误:

enter image description here

那么,管理员是否需要为此应用程序(Web应用程序/ API)授予权限才能使其正常工作?

UPDATE

这是我调用以获取访问令牌的API。

https://login.microsoftonline.com/parkercorp.onmicrosoft.com/oauth2/token

POST BODY:

client_id: app_registration_clientId
client_secret: app_registration_client_secret
grant_type: client_credentials
resource: https://analysis.windows.net/powerbi/api
scope: openid

这是Tom Sun建议的解码令牌。

enter image description here

azure permissions powerbi powerbi-embedded
2个回答
0
投票

如果您选中了“需要管理员”权限,那么是的,您需要管理员才能单击“授予权限”。但是,我不认为您在上面的屏幕截图中选择的两个对于您尝试做的事情是必要的。尝试取消选中它们,授予权限并再次运行请求。


0
投票

那么,管理员是否需要为此应用程序(Web应用程序/ API)授予权限才能使其正常工作?

授予权限失败的根本原因是您需要管理员同意您的管理员才能执行此操作。

由于您希望访问电源BI资源,因此只需检查Power BI服务权限即可。

但根据你的截图,你试图调用qazxsw poi API。

获取Get Dashboard {dashboardKey}

根据该文档,所需的范围是Dashboard.ReadWrite.All或Dashboard.Read.All。无需征得管理员同意。

https://api.powerbi.com/v1.0/myorg/dashboards/

401错误表示没有访问资源的权限。

我们可以使用enter image description here来解码令牌以检查aud和权限。

JWT.io

如果可能,您可以添加代码以获取更有用的令牌。

© www.soinside.com 2019 - 2024. All rights reserved.