Skip to content

Commit 58ccbfc

Browse files
committed
Edit pass.
1 parent e3c929f commit 58ccbfc

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

docs/spfx/overview-graphhttpclient.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Overview of the GraphHttpClient class
22

3-
You can use Microsoft Graph to build powerful solutions that access data from Office 365 services. Connecting SharePoint Framework (SPFx) solutions to Microsoft Graph requires you to register an Azure Active Directory (Azure AD) application and complete the authorization flow. To make this easier, you can use the SPFx **GraphHttpClient** class to call Microsoft Graph directly, without any additional setup.
3+
You can use Microsoft Graph to build powerful solutions that access data from Office 365 and other Microsoft services. To connect SharePoint Framework (SPFx) solutions to Microsoft Graph, you have to register an Azure Active Directory (Azure AD) application and complete the authorization flow. To make this easier, you can use the SPFx **GraphHttpClient** class to call Microsoft Graph directly, without any additional setup.
44

55
> **Important:** The **GraphHttpClient** class is currently in developer preview and is subject to change. We don't recommend that you use it in your production environment.
66
7-
## What is GraphHttpClient?
7+
## What is the GraphHttpClient class?
88

9-
GraphHttpClient is a specialized HTTP client provided as a part of the SharePoint Framework. It works similarly to the HttpClient that you can use to communicate with third party APIs. On top of the HttpClient, the GraphHttpClient automatically ensures that your request to the Microsoft Graph has a valid bearer access token and required headers. Whenever you issue a GET or a POST request, the GraphHttpClient verifies that it has a valid access token, and if it doesn't, it automatically retrieves one from an internal API and stores it for subsequent requests.
9+
The **GraphHttpClient** class is included as part of the SharePoint Framework. It works in a similar way to the HttpClient that you can use to communicate with third-party APIs. The **GraphHttpClient** class automatically ensures that your request to Microsoft Graph has a valid bearer access token and the required headers. When you issue a GET or a POST request, **GraphHttpClient** verifies that it has a valid access token, and if it doesn't, it automatically retrieves one from an internal API and stores it for subsequent requests.
1010

11-
A sample request to the Microsoft Graph using the GraphHttpClient looks as follows:
11+
The following example shows a request to Microsoft Graph that uses the **GraphHttpClient** class.
1212

1313
```ts
1414
// ...
@@ -31,34 +31,36 @@ export default class MyApplicationCustomizer
3131
}
3232
}
3333
```
34+
To make a request to Microsoft Graph:
3435

35-
You start with importing the **GraphHttpClient** and **GraphClientResponse** modules from the **@microsoft/sp-http** package. Next, using the instance of the GraphHttpClient available on the `this.context.graphHttpClient` property, you issue a GET or a POST request to the Microsoft Graph. As the parameters, you specify the Microsoft Graph API that you want to call (starting with the API version without a leading `/` - slash), followed by the GraphHttpClient configuration. Optionally, you can specify additional request headers that will be merged with the default headers set by the GraphHttpClient (`'Accept': 'application/json'`, `'Authorization': 'Bearer [token]'` and `'Content-Type': 'application/json; charset=utf-8'`).
36+
- Import the **GraphHttpClient** and **GraphClientResponse** modules from the **@microsoft/sp-http** package.
37+
- Use the instance of **GraphHttpClient** that's available on the `this.context.graphHttpClient` property to issue a GET or POST request to Microsoft Graph.
38+
- As parameters, specify the Microsoft Graph API that you want to call (start with the API version without a leading `/` - slash), followed by the **GraphHttpClient** configuration.
39+
- Optionally, you can specify additional request headers that will be merged with the default headers set by **GraphHttpClient** (`'Accept': 'application/json'`, `'Authorization': 'Bearer [token]'` and `'Content-Type': 'application/json; charset=utf-8'`).
3640

37-
## GraphHttpClient considerations
41+
## Considerations for using the **GraphHttpClient** class
3842

39-
Using the GraphHttpClient is a very convenient way of communicating with the Microsoft Graph as it abstracts away the authorization flow and management of access tokens. The GraphHttpClient is currently in developer preview and there are some considerations that you should take into account before using it.
43+
The **GraphHttpClient** class provides a convenient way to communicate with Microsoft Graph because it abstracts the authorization flow and management of access tokens. Because **GraphHttpClient** is currently in developer preview, there are some considerations that you should take into account before using it.
4044

4145
### Use for Microsoft Graph access only
4246

43-
The GraphHttpClient is meant to be used only to access Microsoft Graph. The URL specified in the request must begin with the version of the Microsoft Graph API (either **v1.0** or **beta**), followed by the API operation. Any other URL will return an error.
47+
Use the **GraphHttpClient** class only to access Microsoft Graph. The URL specified in the request must begin with the version of the Microsoft Graph API (either **v1.0** or **beta**), followed by the API operation. Any other URL will return an error.
4448

4549
### Permissions
4650

47-
The GraphHttpClient uses the **Office 365 SharePoint Online** Azure AD application to retrieve a valid access token to Microsoft Graph on behalf of the current user. The retrieved access token contains two permissionss:
51+
The GraphHttpClient uses the Office 365 SharePoint Online Azure AD application to retrieve a valid access token to Microsoft Graph on behalf of the current user. The retrieved access token contains two permissions:
4852

49-
* **Read and write all groups (preview)** (`Group.ReadWrite.All`)
50-
* **Read all usage reports** (`Reports.Read.All`)
53+
* Read and write all groups (preview) (`Group.ReadWrite.All`)
54+
* Read all usage reports (`Reports.Read.All`)
5155

52-
At this moment these are the only two permissions available when using the GraphHttpClient. If you need other permission scopes in your solution, you can use [ADAL JS with implicit OAuth flow](web-parts/guidance/call-microsoft-graph-from-your-web-part.md) instead.
56+
These are the only permissions that are available when you use **GraphHttpClient**. If you need other permissions for your solution, you can use [ADAL JS with implicit OAuth flow](web-parts/guidance/call-microsoft-graph-from-your-web-part.md) instead.
5357

5458
### Tokens are retrieved using an internal API
5559

56-
To acquire a valid access token, the GraphHttpClient issues a web request to the `/_api/SP.OAuth.Token/Acquire` endpoint. This API is intended for internal use and you should not communicate with it directly in your solutions.
60+
To acquire a valid access token, **GraphHttpClient** issues a web request to the `/_api/SP.OAuth.Token/Acquire` endpoint. This API is intended for internal use. You should not communicate with it directly in your solutions.
5761

58-
## More information
62+
## See also
5963

60-
To see how the GraphHttpClient can be used in practice, see a sample solution on GitHub at [https://github.com/SharePoint/sp-dev-fx-extensions/tree/master/samples/js-application-graph-client](https://github.com/SharePoint/sp-dev-fx-extensions/tree/master/samples/js-application-graph-client).
61-
62-
To learn how to build a web part that can GET and POST REST calls to Microsoft Graph, see [Call the Microsoft Graph using GraphHttpClient](call-microsoft-graph-using-graphhttpclient.md)
63-
64-
For more information about the Microsoft Graph visit [https://developer.microsoft.com/en-us/graph/](https://developer.microsoft.com/en-us/graph/).
64+
- [Application Customizer GraphClient from Modern Teamsite sample](https://github.com/SharePoint/sp-dev-fx-extensions/tree/master/samples/js-application-graph-client).
65+
- [Use GraphHttpClient to call Microsoft Graph](call-microsoft-graph-using-graphhttpclient.md)
66+
- [Microsoft Graph Dev Center](https://developer.microsoft.com/en-us/graph/)

0 commit comments

Comments
 (0)