Skip to content

Commit d68d6cf

Browse files
waldekmastykarzVesaJuvonen
authored andcommitted
Updated the GraphHttpClient guidance (SharePoint#956)
1 parent e18cc51 commit d68d6cf

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

docs/spfx/overview-graphhttpclient.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Overview of the GraphHttpClient class (preview)
22

33
> [!IMPORTANT]
4-
>The **GraphHttpClient** is currently in preview and is subject to change. It is not currently supported for use in production environments.
4+
> The **GraphHttpClient** is currently in preview and is subject to change. It is not currently supported for use in production environments.
55
66
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.
77

@@ -13,7 +13,7 @@ The following example shows a request to Microsoft Graph that uses the **GraphHt
1313

1414
```ts
1515
// ...
16-
import { GraphHttpClient, GraphClientResponse } from '@microsoft/sp-http';
16+
import { GraphHttpClient, GraphHttpClientResponse } from '@microsoft/sp-http';
1717

1818
export default class MyApplicationCustomizer
1919
extends BaseApplicationCustomizer<IMyApplicationCustomizerProperties> {
@@ -23,7 +23,7 @@ export default class MyApplicationCustomizer
2323
@override
2424
public onRender(): void {
2525
this.context.graphHttpClient.get("v1.0/groups?$select=displayName", GraphHttpClient.configurations.v1)
26-
.then((response: GraphClientResponse): Promise<any> => {
26+
.then((response: GraphHttpClientResponse): Promise<any> => {
2727
return response.json();
2828
})
2929
.then((data: any): void => {
@@ -32,27 +32,28 @@ export default class MyApplicationCustomizer
3232
}
3333
}
3434
```
35+
3536
To make a request to Microsoft Graph:
3637

37-
- Import the **GraphHttpClient** and **GraphClientResponse** modules from the **@microsoft/sp-http** package.
38-
- Use the instance of **GraphHttpClient** that's available on the `this.context.graphHttpClient` property to issue a GET or POST request to Microsoft Graph.
39-
- 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.
38+
- Import the **GraphHttpClient** and **GraphHttpClientResponse** modules from the **@microsoft/sp-http** package.
39+
- Use the instance of **GraphHttpClient** that's available on the `this.context.graphHttpClient` property to issue a GET or POST request to Microsoft Graph.
40+
- 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.
4041
- 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'`).
4142

4243
## Considerations for using the **GraphHttpClient** class
4344

44-
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.
45+
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.
4546

4647
### Use for Microsoft Graph access only
4748

4849
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.
4950

5051
### Permissions
5152

52-
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:
53+
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:
5354

54-
* Read and write all groups (preview) (`Group.ReadWrite.All`)
55-
* Read all usage reports (`Reports.Read.All`)
55+
- Read and write all groups (preview) (`Group.ReadWrite.All`)
56+
- Read all usage reports (`Reports.Read.All`)
5657

5758
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.
5859

0 commit comments

Comments
 (0)