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: README.md
+40-25Lines changed: 40 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,24 +16,32 @@ The Microsoft Graph JavaScript client library is a lightweight wrapper around th
16
16
npm install @microsoft/microsoft-graph-client
17
17
```
18
18
19
-
import `@microsoft/microsoft-graph-client` into your module.
19
+
import `@microsoft/microsoft-graph-client` into your module and also you will need polyfills for fetch like [isomorphic-fetch](https://www.npmjs.com/package/isomorphic-fetch).
Incase if your application ships with [es6-promise](https://www.npmjs.com/package/es6-promise) and [isomorphic-fetch](https://www.npmjs.com/package/isomorphic-fetch)just use `lib/graph-js-sdk-core.js`
34
+
In case your browser doesn't have support for [Fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)[[support](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API#Browser_compatibility)] or [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)[[support](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise#Browser_compatibility)], you need to use polyfills like [github/fetch](https://github.com/github/fetch)for fetch and [es6-promise](https://github.com/stefanpenner/es6-promise) for promise.
@@ -47,11 +55,11 @@ Register your application to use Microsoft Graph API using one of the following
47
55
48
56
### 2. Authenticate for the Microsoft Graph service
49
57
50
-
The Microsoft Graph JavaScript Client Library has an adapter implementation ([MSALAuthenticationProvider](src/MSALAuthenticationProvider.ts)) for [MSAL](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-core) (Microsoft Authentication Library) which takes care of getting the `accessToken`. MSAL library does not ship with this library, user has to include it externally (For including MSAL, refer [this](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-core#installation)).
58
+
The Microsoft Graph JavaScript Client Library has an adapter implementation ([ImplicitMSALAuthenticationProvider](src/ImplicitMSALAuthenticationProvider.ts)) for [MSAL](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-core) (Microsoft Authentication Library) which takes care of getting the `accessToken`. MSAL library does not ship with this library, user has to include it externally (For including MSAL, refer [this](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-core#installation)).
51
59
52
-
> **Note:** MSAL is supported only for frontend applications, for server-side authentication you have to implement your own AuthenticationProvider. Refer implementing[Custom Authentication Provider](./docs/CustomAuthenticationProvider.md).
60
+
> **Important Note:** MSAL is supported only for frontend applications, for server-side authentication you have to implement your own AuthenticationProvider. Learn how you can create a[Custom Authentication Provider](./docs/CustomAuthenticationProvider.md).
53
61
54
-
#### Creating an instance of MSALAuthenticationProvider in browser environment
62
+
#### Creating an instance of ImplicitMSALAuthenticationProvider in browser environment
55
63
56
64
Refer devDependencies in [package.json](./package.json) for the compatible msal version and update that version in below.
57
65
@@ -60,20 +68,24 @@ Refer devDependencies in [package.json](./package.json) for the compatible msal
60
68
```
61
69
62
70
```typescript
63
-
const clientId ="your_client_id"; // Client Id of the registered application
// An Optional options for initializing the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics#configuration-options
66
-
const options = {
67
-
redirectUri: "Your redirect URI",
71
+
72
+
// Configuration options for MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL.js-1.0.0-api-release#configuration-options
73
+
const msalConfig = {
74
+
auth: {
75
+
clientId: "your_client_id"; // Client Id of the registered application
76
+
redirectUri: "your_redirect_uri",
77
+
},
68
78
};
69
79
const graphScopes = ["user.read", "mail.send"]; // An array of graph scopes
70
80
71
-
// Initialize the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics#initialization-of-msal
// An Optional options for initializing the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics#configuration-options
92
-
const options = {
93
-
redirectUri: "Your redirect URI",
102
+
const msalConfig = {
103
+
auth: {
104
+
clientId: "your_client_id", // Client Id of the registered application
105
+
redirectUri: "your_redirect_uri",
106
+
},
94
107
};
95
108
const graphScopes = ["user.read", "mail.send"]; // An array of graph scopes
96
109
97
-
// Initialize the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics#initialization-of-msal
User can integrate own preferred authentication library by implementing `IAuthenticationProvider` interface. Refer implementing [Custom Authentication Provider](./docs/CustomAuthenticationProvider.md).
Copy file name to clipboardExpand all lines: docs/CreatingClientInstance.md
+15-3Lines changed: 15 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,12 +10,24 @@ In order to instantiate a Client object, one has to pass in the `authProvider` o
10
10
11
11
Pass an instance of a class which implements [AuthenticationProvider](../src/IAuthenticationProvider.ts) interface as `authProvider` in [ClientOptions](../src/IClientOptions.ts), which will instantiate the Client with default set of middleware chain.
12
12
13
-
Library is shipped with one such authentication provider named [MSALAuthenticationProvider](../src/MSALAuthenticationProvider.ts). This MSALAuthenticationProvider depends on an authentication library [msal.js](https://github.com/AzureAD/microsoft-authentication-library-for-js) which is not shipped along with the library, one has to externally include msal.js to use MSALAuthenticationProvider.
13
+
Library is shipped with one such authentication provider named [ImplicitMSALAuthenticationProvider](../src/ImplicitMSALAuthenticationProvider.ts). This ImplicitMSALAuthenticationProvider depends on an authentication library [msal.js](https://github.com/AzureAD/microsoft-authentication-library-for-js) which is not shipped along with the library, one has to externally include msal.js to use ImplicitMSALAuthenticationProvider.
14
14
15
15
```typescript
16
-
// Instantiating Client with MSALAuthenticationProvider
16
+
// Instantiating Client with ImplicitMSALAuthenticationProvider
17
+
18
+
// An Optional options for initializing the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics#configuration-options
19
+
const msalConfig = {
20
+
auth: {
21
+
clientId: <CLIENT_ID> // Client Id of the registered application
22
+
},
23
+
};
24
+
25
+
// Important Note: This library implements loginPopup and acquireTokenPopup flow, remember this while initializing the msal
26
+
// Initialize the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js#1-instantiate-the-useragentapplication
Copy file name to clipboardExpand all lines: docs/CustomMiddlewareChain.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,14 +68,14 @@ Can use own middlewares and the ones shipped with the library [[Here](../src/mid
68
68
69
69
Using AuthenticationHandler [one shipped with the library] and MyLoggingHandler, and MyHttpMessageHandler [custom ones] to create a middleware chain here.
70
70
71
-
NOTE: Instead of MSALAuthenticationProvider, one can provide his own Authentication Handler. For more about using custom authentication provider, refer [here](./CustomAuthenticationProvider.md).
71
+
NOTE: Instead of ImplicitMSALAuthenticationProvider, one can provide his own Authentication Handler. For more about using custom authentication provider, refer [here](./CustomAuthenticationProvider.md).
0 commit comments