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 17, 2024. It is now read-only.
@@ -295,7 +295,7 @@ This sample app declares that it's CAE-capable by adding the `clientCapabilities
295
295
296
296
#### Processing the CAE challenge from Microsoft Graph
297
297
298
-
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 `acquireTokenRedirect` API and provide the claims challenge as a parameter in the token request. This is shown in [graph.service.ts](../SPA/src/app/graph.service.ts), where we handle the response from the Microsoft Graph API with the `handleClaimsChallenge` method:
298
+
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 `acquireToken` API and provide the claims challenge as a parameter in the token request. This is shown in [graph.service.ts](../SPA/src/app/graph.service.ts), where we handle the response from the Microsoft Graph API with the `handleClaimsChallenge` method:
299
299
300
300
```typescript
301
301
/**
@@ -304,20 +304,19 @@ Once the client app receives the CAE claims challenge from Microsoft Graph, it n
304
304
* For more information, visit: https://docs.microsoft.com/en-us/azure/active-directory/develop/claims-challenge#claims-challenge-header-format
@@ -341,36 +340,7 @@ Once the client app receives the CAE claims challenge from Microsoft Graph, it n
341
340
342
341
```
343
342
344
-
After that, we require a new access token via the `acquireTokenRedirect` API, fetch the claims challenge from the browser's localStorage, and pass it to the `acquireTokenRedirect` hook in the request parameter.
After that, we require a new access token via the `MsalAuthenticationProvider` Class, fetch the claims challenge from the browser's localStorage, and pass it to the `acquireToken` API in the request parameter. This is shown in [graph.service.ts](../SPA/src/app/graph.service.ts)
374
344
375
345
### Working with multiple resources
376
346
@@ -432,35 +402,162 @@ Clients should treat access tokens as opaque strings, as the contents of the tok
432
402
433
403
### Calling the Microsoft Graph API
434
404
435
-
Using the httpClient , simply add the Authorization header to your request, followed by the access token you have obtained previously for this resource/endpoint (as a bearer token):
405
+
[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 [clientOptions](https://github.com/microsoftgraph/msgraph-sdk-javascript/blob/dev/docs/CreatingClientInstance.md) method, which contains an `authProvider` object of class **MyAuthenticationProvider** that handles the token acquisition process for the client. We offer this as a service to other components as shown below:
436
406
437
407
```typescript
438
-
/**
439
-
* Makes a GET request using authorization header For more, visit:
**MyAuthenticationProvider** class needs to implement the [IAuthenticationProvider](https://github.com/microsoftgraph/msgraph-sdk-javascript/blob/dev/src/IAuthenticationProvider.ts) interface, which can be done as shown below:
425
+
426
+
```typescript
427
+
/**
428
+
* This method will get called before every request to the ms graph server
429
+
* This should return a Promise that resolves to an accessToken (in case of success) or rejects with error (in case of failure)
430
+
* Basically this method will contain the implementation for getting and refreshing accessTokens
0 commit comments