You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/spfx/use-msgraph.md
+19-17Lines changed: 19 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -1,35 +1,37 @@
1
1
---
2
-
title: Use the MSGraphClient to connect to Microsoft Graph
3
-
description: Use the MSGraphClient class to make calls to the Microsoft Graph REST API.
4
-
ms.date: 6/21/2022
2
+
title: Use the MSGraphClientV3 to connect to Microsoft Graph
3
+
description: Use the MSGraphClientV3 class to make calls to the Microsoft Graph REST API.
4
+
ms.date: 08/29/2022
5
5
ms.localizationpriority: high
6
6
---
7
7
8
-
# Use the MSGraphClient to connect to Microsoft Graph
8
+
# Use the MSGraphClientV3 to connect to Microsoft Graph
9
9
10
-
When building SharePoint Framework solutions, you can easily connect to the Microsoft Graph by using the **MSGraphClient**.
10
+
When building SharePoint Framework solutions, you can easily connect to the Microsoft Graph by using the **MSGraphClientV3**.
11
11
12
12
## MSGraphClient overview
13
13
14
-
**MSGraphClient** is a new HTTP client introduced in SharePoint Framework v1.6.0 that simplifies connecting to the Microsoft Graph inside SharePoint Framework solutions. **MSGraphClient** wraps the existing [Microsoft Graph JavaScript Client Library](https://www.npmjs.com/package/@microsoft/microsoft-graph-client), offering developers the same capabilities as when using the client library in other client-side solutions.
14
+
**MSGraphClientV3** is a new HTTP client introduced in SharePoint Framework v1.15.0 that simplifies connecting to the Microsoft Graph inside SharePoint Framework solutions. **MSGraphClientV3** wraps the [Microsoft Graph JavaScript Client Library v3](https://www.npmjs.com/package/@microsoft/microsoft-graph-client), offering developers the same capabilities as when using the client library in other client-side solutions.
15
15
16
-
While you could use the Microsoft Graph JavaScript Client Library in your solution directly, **MSGraphClient** handles authenticating against the Microsoft Graph for you, which allows you to focus on building your solution.
16
+
**MSGraphClientV3** replaces **MSGraphClient** which was introduced in SharePoint Framework v1.6.0. **MSGraphClient** wrapped the Microsoft Graph JavaScript Client Library v1.
17
+
18
+
While you could use the Microsoft Graph JavaScript Client Library in your solution directly, **MSGraphClientV3** handles authenticating against the Microsoft Graph for you, which allows you to focus on building your solution.
17
19
18
20
## Use the MSGraphClient in your solution
19
21
20
22
> [!NOTE]
21
-
> The **MSGraphClient** is available only in projects built using SharePoint Framework v1.6.0 and later. While the **MSGraphClient** is explained in this article by using a client-side web part, you can also use it in SharePoint Framework Extensions.
23
+
> The **MSGraphClientV3** is available only in projects built using SharePoint Framework v1.15.0 and later. While the **MSGraphClientV3** is explained in this article by using a client-side web part, you can also use it in SharePoint Framework Extensions.
22
24
23
25
> [!NOTE]
24
-
> The single sign-on for the **MSGraphClient** is only available in SharePoint Online today. You can leverage the client for on premises developments but your users will be requested to sign in again within the webpart.
26
+
> The single sign-on for the **MSGraphClientV3** is only available in SharePoint Online today. You can leverage the client for on premises developments but your users will be requested to sign in again within the webpart.
25
27
26
-
1. To use the **MSGraphClient** in your SharePoint Framework solution, add the following `import` clause in your main web part file:
28
+
1. To use the **MSGraphClientV3** in your SharePoint Framework solution, add the following `import` clause in your main web part file:
27
29
28
30
```typescript
29
-
import { MSGraphClient } from '@microsoft/sp-http';
31
+
import { MSGraphClientV3 } from '@microsoft/sp-http';
30
32
```
31
33
32
-
1. **MSGraphClient** is exposed through the **MSGraphClientFactory** available on the web part context. To get a reference to MSGraphClient, in your code add:
34
+
1. **MSGraphClientV3** is exposed through the **MSGraphClientFactory** available on the web part context. To get a reference to MSGraphClient, in your code add:
33
35
34
36
```typescript
35
37
export default class HelloWorldWebPart extends BaseClientSideWebPart<IHelloWorldWebPartProps> {
@@ -38,7 +40,7 @@ While you could use the Microsoft Graph JavaScript Client Library in your soluti
38
40
39
41
this.context.msGraphClientFactory
40
42
.getClient('3')
41
-
.then((client: MSGraphClient): void => {
43
+
.then((client: MSGraphClientV3): void => {
42
44
// use MSGraphClient here
43
45
});
44
46
}
@@ -47,7 +49,7 @@ While you could use the Microsoft Graph JavaScript Client Library in your soluti
47
49
}
48
50
```
49
51
50
-
1. After you have the reference to the **MSGraphClient** instance, start communicating with the Microsoft Graph by using its JavaScript Client Library syntax:
52
+
1. After you have the reference to the **MSGraphClientV3** instance, start communicating with the Microsoft Graph by using its JavaScript Client Library syntax:
51
53
52
54
```typescript
53
55
export default class HelloWorldWebPart extends BaseClientSideWebPart<IHelloWorldWebPartProps> {
@@ -56,7 +58,7 @@ While you could use the Microsoft Graph JavaScript Client Library in your soluti
56
58
57
59
this.context.msGraphClientFactory
58
60
.getClient('3')
59
-
.then((client: MSGraphClient): void => {
61
+
.then((client: MSGraphClientV3): void => {
60
62
// get information about the current user from the Microsoft Graph
61
63
client
62
64
.api('/me')
@@ -95,11 +97,11 @@ When working with the Microsoft Graph and TypeScript, you can use the [Microsoft
95
97
96
98
this.context.msGraphClientFactory
97
99
.getClient('3')
98
-
.then((client: MSGraphClient): void => {
100
+
.then((client: MSGraphClientV3): void => {
99
101
// get information about the current user from the Microsoft Graph
0 commit comments