硬件仪表板 API

使用“Microsoft 硬件 API”以编程方式在组织的合作伙伴中心帐户中查询和创建硬件产品提交。 如果你的帐户管理多个产品,并且你想要自动执行并优化这些资源的提交过程,那么这些 API 非常有用。 这些 API 使用 Microsoft Entra ID (Microsoft Entra ID) 对来自应用或服务的调用进行身份验证。

只有属于 硬件合作伙伴中心计划的 帐户才能使用硬件仪表板 API。 下面是使用Microsoft硬件 API 的端到端过程:

  1. 在下一部分中完成先决条件。

  2. 在Microsoft硬件 API 中调用方法之前,先获取Microsoft Entra ID 访问令牌。 获得令牌后,需要 60 分钟才能在令牌过期之前在对 Microsoft Store 提交 API 的调用中使用令牌。 令牌过期后,可以生成一个新令牌。

  3. 调用“Microsoft 硬件 API”。

完成使用“Microsoft 硬件 API”的先决条件

在开始编写代码以调用Microsoft硬件 API 之前,必须完成以下必需的先决条件:

为 Microsoft Entra ID 应用程序分配适当的硬件角色

完成先决条件后,请分配相应的角色,以便Microsoft Entra ID 应用程序可以创建和管理提交和发货标签。

  1. From Partner Center, select the gear icon (near the upper right corner of the dashboard) and then select Developer settings. In the Settings menu, select Users.

  2. On the Users page, select Microsoft Entra ID applications and the Microsoft Entra ID application that represents the app or service you use to access submissions for your Partner Center account.

  3. On this page, under Roles, select Hardware.

    显示“角色”部分中的“硬件”选项卡的屏幕截图。

    Select Driver Submitter, Shipping Label owner, and if available, Shipping Label promoter. 详细了解这些角色

获取 Microsoft Entra ID 访问令牌

Before you call any of the methods in the Microsoft Hardware API, you must first obtain a Microsoft Entra ID access token that you pass to the Authorization header of each method in the API. 获取访问令牌后,在它到期前,你有 60 分钟的使用时间。 该令牌到期后,可以对它进行刷新,以便可以在之后调用该 API 时继续使用。 要获取访问令牌,请按照 使用客户端凭据的服务到服务调用 中的说明将 HTTP POST 发送到 https://login.microsoftonline.com/<tenant_id>/oauth2/token 终结点。 下面是一个示例请求。

POST https://login.microsoftonline.com/<tenant_id>/oauth2/token HTTP/1.1
Host: login.microsoftonline.com
Content-Type: application/x-www-form-urlencoded; charset=utf-8

grant_type=client_credentials
&client_id=<your_client_id>
&client_secret=<your_client_secret>
&resource=https://manage.devcenter.microsoft.com

For the tenant_id value in the POST URI and the client_id and client_secret parameters, specify the tenant ID, client ID, and the key for your application that you retrieved from Partner Center in the previous section. For the resource parameter, you must specify https://manage.devcenter.microsoft.com.

在你的访问令牌到期后,你可按照刷新访问令牌中的说明刷新令牌。

使用“Microsoft 硬件 API”

在拥有 Microsoft Entra ID 访问令牌后,就可以调用 Microsoft 硬件 API 中的方法。 该 API 包括许多分组到各个方案中的方法。 要创建或更新提交,一般需在“Microsoft 硬件 API”中按特定顺序调用多个方法。 有关各场景中每个方法的语法信息,请参阅下表中的文章:

Scenario Description
Drivers 获取、创建和更新注册到合作伙伴中心帐户的驱动程序。 有关这些方法的详细信息,请参阅以下文章:

Code sample

以下代码示例提供由 Microsoft Surface 和设备团队创建的完整端到端预生成解决方案:

More help

If you have questions about the Microsoft Store submission API or need assistance managing your submissions with this API, visit the support page and request help.