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
{{ message }}
This repository was archived by the owner on May 3, 2024. It is now read-only.
|`pages/Home.jsx`| Contains a table with ID token claims and description |
36
+
|`pages/Profile.jsx`| Calls Microsoft Graph `/me` by executing `useGraphWithMsal` custom hook.|
37
+
|`pages/Contacts.jsx`| Calls Microsoft Graph `/me/contacts` by executing `useGraphWithMsal` custom hook.|
38
+
|`components/AccountPicker.jsx`| Contains logic to handle multiple `account` selection with MSAL.js |
39
+
|`hooks/useGraphWithMsal.jsx`| Contains token acquisition logic to call Microsoft Graph endpoints with Graph SDK.|
40
40
41
41
## Setup the sample
42
42
@@ -240,95 +240,68 @@ This sample app declares that it's CAE-capable by adding the `clientCapabilities
240
240
241
241
#### Processing the CAE challenge from Microsoft Graph
242
242
243
-
Once the client app receives the CAE claims challenge from Microsoft Graph, it needs to present the user with a prompt for satisfying the challenge via Azure AD authorization endpoint. To do so, we use MSAL's `useMsalAuthentication` hook and provide the claims challenge as a parameter in the token request. This is shown in [fetch.js](./SPA/src/fetch.js), where we handle the response from the Microsoft Graph API with the `handleClaimsChallenge` method:
243
+
Once the client app receives the CAE claims challenge from Microsoft Graph, it needs to present the user with a prompt for satisfying the challenge via Azure AD authorization endpoint. To do so, we use MSAL's `useMsalAuthentication` hook and provide the claims challenge as a parameter in the token request. This is shown in the [useGraphWithMsal](./SPA/src/hooks/useGraphWithMsal.jsx) custom hook:
thrownewError(`Something went wrong with the request: ${response.status}`);
267
-
}
268
-
};
269
-
```
270
-
271
-
After that, we require a new access token via the `useMsalAuthentication` hook, fetch the claims challenge from the browser's localStorage, and pass it to the `useMsalAuthentication` hook in the request parameter.
@@ -340,7 +313,7 @@ For more details on what's inside the access token, clients should use the token
340
313
341
314
### Calling the Microsoft Graph API
342
315
343
-
[Microsoft Graph JavaScript SDK](https://github.com/microsoftgraph/msgraph-sdk-javascript) provides various utility methods to query the Graph API. While the SDK has a default authentication provider that can be used in basic scenarios, it can also be extended to use with a custom authentication provider such as MSAL. To do so, we will initialize the Graph SDK client with an [authProvider function](https://github.com/microsoftgraph/msgraph-sdk-javascript/blob/dev/docs/CreatingClientInstance.md#2-create-with-options). In this case, user has to provide their own implementation for getting and refreshing accessToken. A callback will be passed into this `authProvider` function, accessToken or error needs to be passed in to that callback
316
+
[Microsoft Graph JavaScript SDK](https://github.com/microsoftgraph/msgraph-sdk-javascript) provides various utility methods to query the Graph API. While the SDK has a default authentication provider that can be used in basic scenarios, it can also be extended to use with a custom authentication provider such as MSAL. To do so, we will initialize the Graph SDK client with an [authProvider function](https://github.com/microsoftgraph/msgraph-sdk-javascript/blob/dev/docs/CreatingClientInstance.md#2-create-with-options). In this case, user has to provide their own implementation for getting and refreshing access tokens.
344
317
345
318
```javascript
346
319
exportconstgetGraphClient= (accessToken) => {
@@ -356,29 +329,7 @@ For more details on what's inside the access token, clients should use the token
356
329
};
357
330
```
358
331
359
-
See [graph.js](./SPA/src/graph.js). The Graph client then can be used in your components as shown below:
0 commit comments