Skip to content

Commit 831b449

Browse files
Merge pull request SharePoint#8674 from HarminderSethi/main
updated the reference for MSGraphClient to MSGraphClientV3
2 parents 4046ed1 + c0dbe84 commit 831b449

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

docs/spfx/use-aad-tutorial.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Consume the Microsoft Graph in the SharePoint Framework
33
description: Tutorial on using the AadHttpClient or MSGraphClient class to connect to the Microsoft Graph in SharePoint Framework solutions.
4-
ms.date: 06/13/2022
4+
ms.date: 01/06/2023
55
ms.localizationpriority: high
66
---
77

@@ -14,7 +14,7 @@ Introduced in v1.4.1, you can use the SharePoint Framework to consume Microsoft
1414
In this article, you'll learn how to create a SharePoint Framework solution that uses the Microsoft Graph API with a custom set of permissions. For a conceptual overview of this technology, see [Connect to Azure AD-secured APIs in SharePoint Framework solutions](use-aadhttpclient.md).
1515

1616
> [!IMPORTANT]
17-
> You can consume the Microsoft Graph API with versions of SharePoint Framework earlier than v1.4.1, either via the native **GraphHttpClient**, or by directly using [Microsoft identity platfomr authentication libraries](https://learn.microsoft.com/en-us/azure/active-directory/develop/reference-v2-libraries) implicit OAuth flow. However, the former approach is bound to a predefined set of permissions, which presents some limitations, and the latter is complex from a development perspective. For details about how to implement an implicit OAuth flow, see [Connect to APIs secured with Azure Active Directory](./web-parts/guidance/connect-to-api-secured-with-aad.md).
17+
> You can consume the Microsoft Graph API with versions of SharePoint Framework earlier than v1.4.1, either via the native **GraphHttpClient**, or by directly using [Microsoft identity platfomr authentication libraries](/azure/active-directory/develop/reference-v2-libraries) implicit OAuth flow. However, the former approach is bound to a predefined set of permissions, which presents some limitations, and the latter is complex from a development perspective.
1818
1919
## Solution overview
2020

@@ -252,7 +252,7 @@ Now you can update the **GraphConsumer** React component under the **./src/webpa
252252
} from "office-ui-fabric-react";
253253
import * as React from "react";
254254
255-
import { AadHttpClient, MSGraphClient } from "@microsoft/sp-http";
255+
import { AadHttpClient, MSGraphClientV3 } from "@microsoft/sp-http";
256256
import { escape } from "@microsoft/sp-lodash-subset";
257257
258258
import { ClientMode } from "./ClientMode";
@@ -453,11 +453,11 @@ When you package and deploy your solution, you (or an admin) will have to grant
453453
You can now implement the methods to consume the Microsoft Graph. You have two options:
454454

455455
- Use the **AadHttpClient** client object
456-
- Use the **MSGraphClient** client object
456+
- Use the **MSGraphClientV3** client object
457457

458458
The **AadHttpClient** client object is useful for consuming any REST API. You can use it to consume Microsoft Graph or any other third-party (or first-party) REST API.
459459

460-
The **MSGraphClient** client object can consume the Microsoft Graph only. Internally it uses the **AadHttpClient** client object and supports the fluent syntax of the Microsoft Graph SDK.
460+
The **MSGraphClientV3** client object can consume the Microsoft Graph only. Internally it uses the **AadHttpClient** client object and supports the fluent syntax of the Microsoft Graph SDK.
461461

462462
### Using AadHttpClient
463463

@@ -524,9 +524,9 @@ private _searchWithAad = (): void => {
524524

525525
The `get()` method gets the URL of the OData request as the input argument. A successful request returns a JSON object with the response.
526526

527-
### Using MSGraphClient
527+
### Using MSGraphClientV3
528528

529-
If you're targeting Microsoft Graph, you can use the **MSGraphClient** client object, which provides a more fluent syntax.
529+
If you're targeting Microsoft Graph, you can use the **MSGraphClientV3** client object, which provides a more fluent syntax.
530530

531531
The following example shows the implementation of the `_searchWithGraph()` method of the sample solution.
532532

@@ -537,8 +537,8 @@ private _searchWithGraph = () : void => {
537537
console.log("Using _searchWithGraph() method");
538538

539539
this.props.context.msGraphClientFactory
540-
.getClient()
541-
.then((client: MSGraphClient) => {
540+
.getClient('3')
541+
.then((client: MSGraphClientV3) => {
542542
// From https://github.com/microsoftgraph/msgraph-sdk-javascript sample
543543
client
544544
.api("users")
@@ -575,7 +575,7 @@ private _searchWithGraph = () : void => {
575575
}
576576
```
577577

578-
You get an instance of the `MSGraphClient` type by calling the `context.msGraphClientFactory.getClient()` method.
578+
You get an instance of the `MSGraphClientV3` type by calling the `context.msGraphClientFactory.getClient('3')` method.
579579

580580
You then use the fluent API of the Microsoft Graph SDK to define the OData query that runs against the target Microsoft Graph endpoint.
581581

0 commit comments

Comments
 (0)