You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过MS Graph获取设备列表(含Go SDK及直连方案)

获取MS Graph设备列表的解决方案

直接API请求方案

获取所有Azure AD设备

使用GET https://graph.microsoft.com/v1.0/devices端点,该接口专门返回Azure AD中注册的设备对象,不会与普通用户、会议室账号混杂。你可以通过$filter参数筛选特定类型的设备,示例:

GET https://graph.microsoft.com/v1.0/devices?$filter=deviceType eq 'Desktop'

获取会议室专用设备

如果需要获取会议室配套的设备(如视频会议设备),可针对roomDevice类型查询places端点:

GET https://graph.microsoft.com/v1.0/places/microsoft.graph.roomDevice

Go SDK实现方案

获取所有Azure AD设备

使用Microsoft Graph Go SDK v10版本,调用Devices().Get()方法即可获取设备列表,示例代码:

import (
    "context"
    msgraph "github.com/microsoftgraph/msgraph-sdk-go/v10/msgraph"
)

// 假设g.userClient已完成初始化并拥有对应权限
devices, err := g.userClient.Devices().Get(context.Background(), nil)
if err != nil {
    // 处理错误逻辑
}

// 遍历设备列表
for _, device := range devices.GetValue() {
    deviceId := *device.GetId()
    displayName := *device.GetDisplayName()
    // 按需处理设备属性
}

获取会议室专用设备

对应places接口的roomDevice类型,调用Places().GraphRoomDevice().Get()方法:

roomDevices, err := g.userClient.Places().GraphRoomDevice().Get(context.Background(), nil)
if err != nil {
    // 处理错误逻辑
}

// 遍历会议室设备列表
for _, device := range roomDevices.GetValue() {
    // 按需处理设备属性
}

权限要求

调用上述接口需要对应的应用权限或委派权限:

  • 针对/devices接口:Device.Read.All、Directory.Read.All等权限
  • 针对/places/microsoft.graph.roomDevice接口:Place.Read.All等权限

内容的提问来源于stack exchange,提问作者zdevaty

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.16 19:42:51