如何将 Power BI 连接到 Microsoft 365 管理中心

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

我正在阅读这篇令人惊叹的文档:

https://learn.microsoft.com/en-us/office/office-365-management-api/get-started-with-office-365-management-apis

我的目标是尝试访问 Microsoft 365 管理中心并提取我们的用户列表,每个用户都有其许可证:

enter image description here

我必须指向的URL是这样的:https://admin.microsoft.com/Adminportal/Home#/users

但是当我尝试连接 Power BI 时,我收到错误

A web API key can only be specified when a web API key name is provided

enter image description here

但我提供了我在文档中创建的密钥。

我做错了什么?

还有其他方法可以访问我们的许可证列表吗?

powerbi powerbi-desktop powerbi-datasource microsoft365 azure-app-registration
1个回答
0
投票

首先,注册一个 Microsoft Entra 应用程序,并通过授予同意来添加应用程序类型的

Reports.Read.All
权限,如下所示:

enter image description here

您可以通过 Postman 使用具有以下参数的客户端凭据流生成访问令牌:

POST https://login.microsoftonline.com/tenantId/oauth2/v2.0/token

grant_type:client_credentials
client_id: appId
client_secret: secret
scope: https://graph.microsoft.com/.default

回复:

enter image description here

现在,您可以使用此访问令牌调用 Microsoft Graph API 来获取用户及其许可证:

GET https://graph.microsoft.com/v1.0/reports/getOffice365ActiveUserDetail(period='D7')
Authorization: Bearer <token>

回复:

enter image description here

在 Power BI Desktop 中,您可以通过选择

Advanced
并包含带有不记名令牌的 Authorization 标头来创建 Web 连接,如下所示:

enter image description here

这会提取包含用户列表及其分配的许可证的数据,如下所示:

enter image description here

参考:

已解决:从 M365 连接到 P... 的许可证和用户列表 - Microsoft Fabric Community by v-shex-msft

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