使用 Graph 浏览器Working with Graph Explorer

Graph 浏览器 是一款开发人员工具,可方便你提出 Microsoft Graph REST API 请求并查看相应的响应。Graph Explorer is a developer tool that lets you conveniently make Microsoft Graph REST API requests and view corresponding responses. 本文介绍如何使用 Graph 资源管理器中的一些重要功能。This article describes how to use some of the important features in Graph Explorer.

用户或管理员必须通过同意过程授予 Graph 资源管理器访问 Microsoft Graph 中数据的正确权限。The user or administrator must grant Graph Explorer the correct permissions via a consent process to access data in Microsoft Graph. 登录时,通过"修改权限 "选项卡或 配置文件旁边的设置齿轮中的"选择权限"选项同意 Graph 资源管理器中的权限。Consent to permissions in Graph Explorer either via the Modify permissions tab or the Select permissions option in the settings gear next to your profile when you’re signed in. " 修改权限" 选项卡列出了在地址栏中运行查询所需的所有权限。The Modify permissions tab lists all permissions you need to run the query in the address bar.

同意权限:To consent to permissions:

  1. 选择一个示例查询并运行它。Select a sample query and run it.
  2. 选择 "修改权限" 选项卡。Select the Modify permissions tab.
  3. 请参阅运行查询所需的权限列表。See the list of permissions required to run the query.
  4. 选择要同意的权限旁边的同意按钮。Select the consent button next to the permission you want to consent to.

Graph 资源管理器屏幕截图,其中突出显示了同意权限的步骤

" 修改权限" 功能当前处于预览阶段,并且某些查询可能缺少权限。The Modify permissions feature is currently in preview, and some queries might be missing permissions. 如果查询缺少权限,则配置文件旁边的设置齿轮中的"选择权限"选项将包含所有可用权限的列表:If permissions are missing for a query, the Select permissions option in the settings gear next to your profile contains the list of all available permissions:

  1. 转到设置齿轮,然后单击 "选择权限" 选项。Go the settings gear and click the Select permissions option. 此选项包含所有可用权限的列表。This option contains the list of all available permissions.
  2. 从所有权限列表中,同意所需的权限。From the list of all the permissions, consent to the ones you want.

突出显示"选择权限"选项的图形资源管理器屏幕截图

获取访问或身份验证令牌Get an access or authentication token

Graph 资源管理器包含 一个访问令牌 选项卡,可显示登录时的访问令牌。Graph Explorer includes an Access token tab that shows your access token when you are signed in. "访问令牌 "选项卡上,如果需要在常用 REST 客户端应用程序中使用它,可以复制令牌。On the Access token tab, you can copy the token if you need to use it in your favorite REST client application.

Graph 资源管理器中"访问令牌"选项卡的屏幕截图,其中突出显示了"复制"按钮

复制代码段Copy code snippets

对于你在 Graph 资源管理器中选择或输入的每个 REST API 查询,你可以找到如何在代码段选项卡 -C#、Java、JavaScript 和 Objective-C 下展示的四种语言中调用该 API。 For each REST API query you select or enter in Graph Explorer, you can find how to call that API in each of the four languages showcased under the Code snippets tab - C#, Java, JavaScript, and Objective-C.

突出显示代码段选项卡的 Graph 资源管理器屏幕截图

UI 组件集成UI component integration

Graph 资源管理器包括多个功能,以便更轻松地实现 UI。Graph Explorer includes several features to make implementing UI easier. 在应用中也重复使用这些组件。Reuse these components in your apps too.

Microsoft Graph Toolkit集成Microsoft Graph Toolkit integration

Microsoft Graph Toolkit是可重用的、与框架无关的 Web 组件和帮助程序的集合,用于访问和使用 Microsoft Graph。The Microsoft Graph Toolkit is a collection of reusable, framework-agnostic web components and helpers for accessing and working with Microsoft Graph. 这些组件具有功能齐全的功能,内置提供程序使用 Microsoft Graph 进行身份验证并提取数据。The components are fully functional, with built in providers that authenticate with and fetch data from Microsoft Graph.

Graph 资源管理器提供与 Microsoft Graph 和组件Toolkit REST API 查询。Graph Explorer provides sample REST API queries that correspond to Microsoft Graph Toolkit components. Toolkit 组件 选项卡上的一个蓝点指示Toolkit在 Graph 资源管理器中为当前指定的 REST API 查询提供组件。A blue dot on the Toolkit component tab indicates that the Toolkit provides a component for the currently specified REST API query in Graph Explorer. 你可以方便地将组件的代码复制到你的应用。You can conveniently copy the code for the component to your app.

下表列出了当前包含应用程序组件的示例Toolkit查询。The following table lists the sample queries that currently include a Toolkit component.

Graph 浏览器示例查询Graph Explorer sample query Toolkit iFrame URL 示例Toolkit sample iFrame URL
获取我的个人资料GET my profile https://mgt.dev/iframe.html?id=components-mgt-person-card—person-card-hoverhttps://mgt.dev/iframe.html?id=components-mgt-person-card—person-card-hover
获取我合作的人GET people I work with https://mgt.dev/iframe.html?id=components-mgt-people—peoplehttps://mgt.dev/iframe.html?id=components-mgt-people—people
获取我的所有规划器任务GET all my planner tasks https://mgt.dev/iframe.html?id=components-mgt-tasks—taskshttps://mgt.dev/iframe.html?id=components-mgt-tasks—tasks
获取下一周的事件GET my events for the next week https://mgt.dev/iframe.html?id=components-mgt-agenda—get-events-for-next-weekhttps://mgt.dev/iframe.html?id=components-mgt-agenda—get-events-for-next-week
获取我的照片 GET my photo https://mgt.dev/iframe.html?id=components-mgt-person—仅个人照片https://mgt.dev/iframe.html?id=components-mgt-person—person-photo-only

Screenshot showing the Toolkit components tab with the code to generate the component highlighted

自适应卡片集成Adaptive cards integration

自适应卡片 是 UI 的与平台无关的代码段,在 JSON 中创作,应用和服务可以公开交换。Adaptive cards are platform-agnostic snippets of UI, authored in JSON, that apps and services can openly exchange. 运行查询且自适应卡片可用时,自适应卡片选项卡上会显示一个 蓝色 点。When you run a query and an adaptive card is available, a blue dot appears on the Adaptive cards tab.

Graph 资源管理器中自适应卡片选项卡的屏幕截图,其中突出显示了响应详细信息

在 Graph 资源管理器中自定义主题Customize the theme in Graph Explorer

通过选择设置齿轮下的"更改主题" 选项, 为 Graph 浏览器选择主题。Choose the theme for Graph Explorer by selecting the Change theme option under the settings gear. 主题选项为浅色、深色和高对比度。Theme options are Light, Dark, and High contrast.

Graph 资源管理器中"更改主题"选项的屏幕截图,其中突出显示了主题选项

存储和共享查询Storing and sharing queries

在 Graph 资源管理器中运行的查询在"历史记录"选项卡中保存 30 天。 在"历史记录"选项卡上,您可以:Queries run in Graph Explorer are saved for 30 days in the History tab. On the History tab, you can:

  1. 导出 .har 格式的所有历史记录项。Export all history items in .har format.
  2. 删除所有历史记录项。Delete all history items.
  3. 查看此历史记录项。View this history item.
  4. 运行此查询。Run this query.
  5. 以 .har 格式导出此历史记录项。Export this history item in .har format.
  6. 删除此历史记录项。Delete this history item.

突出显示选项的"历史记录"选项卡的屏幕截图

若要共享您运行的查询,请单击响应窗格中的"共享查询"按钮,然后单击"复制 "。To share queries that you run, click the share query button in the response pane and click copy. 这会复制要共享的链接,并允许其他人查看查询和结果。This copies a link to share and allow others to see your query and the results.

突出显示"共享和复制"选项的 Graph 浏览器屏幕截图

Graph 浏览器 UI 功能Graph Explorer UI features

当你想要扩大请求和响应区域时,在 Graph 资源管理器中折叠并展开边栏组件。Collapse and expand the sidebar component in Graph Explorer when you want to widen the request and response area. 若要折叠边栏组件,请选择边栏左上方的汉堡包图标。To collapse the sidebar component, select the hamburger icon on the top left of the sidebar.

突出显示展开和折叠选项的 Graph 资源管理器屏幕截图

通过选择响应预览窗口中的展开箭头展开和折叠响应预览。Expand and collapse the response preview by selecting the expand arrow in the response preview window.

突出显示展开和折叠选项的响应窗格屏幕截图

通过 Graph 浏览器 UI 方便地访问 Microsoft 365 开发人员计划网站,获取包含要试验的示例数据的免费沙盒。Conveniently access the Microsoft 365 Developer Program site from the Graph Explorer UI to get a free sandbox with sample data to experiment with. 在设置齿轮下,选择 "获取包含示例数据的沙盒"。Under the setting gear, select Get a sandbox with sample data.

突出显示了"获取包含示例数据"选项的沙盒的 Graph 资源管理器屏幕截图

后续步骤Next steps