Skip to content

Commit c50be7f

Browse files
Merge pull request #154 from microsoftgraph/MSALProvider_UserAgentApp
Updated MSALAuthenticationProvider's constructor to accept an instance of UserAgentApplication
2 parents 22d1bad + 4f14963 commit c50be7f

File tree

5 files changed

+787
-788
lines changed

5 files changed

+787
-788
lines changed

README.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,17 @@ Refer devDependencies in [package.json](./package.json) for the compatible msal
6060
```
6161

6262
```typescript
63-
const clientID = "your_client_id"; // Client Id of the registered application
64-
const graphScopes = ["user.read", "mail.send"]; // An array of graph scopes
63+
const clientId = "your_client_id"; // Client Id of the registered application
64+
const callback = (errorDesc, token, error, tokenType) => {};
65+
// An Optional options for initializing the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics#configuration-options
6566
const options = {
66-
// An Optional options for initializing the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics#configuration-options
6767
redirectUri: "Your redirect URI",
6868
};
69-
const authProvider = new MicrosoftGraph.MSALAuthenticationProvider(clientId, graphScopes, options);
69+
const graphScopes = ["user.read", "mail.send"]; // An array of graph scopes
70+
71+
// Initialize the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics#initialization-of-msal
72+
const userAgentApplication = new Msal.UserAgentApplication(clientId, undefined, callback, options);
73+
const authProvider = new MicrosoftGraph.MSALAuthenticationProvider(userAgentApplication, graphScopes);
7074
```
7175

7276
#### Creating an instance of MSALAuthenticationProvider in node environment
@@ -78,15 +82,21 @@ npm install msal@<version>
7882
```
7983

8084
```typescript
85+
import { UserAgentApplication } from "msal";
86+
8187
import { MSALAuthenticationProvider } from "./node_modules/@microsoft/microsoft-graph-client/lib/src/MSALAuthenticationProvider";
8288

8389
const clientId = "your_client_id"; // Client Id of the registered application
84-
const graphScopes = ["user.read", "mail.send"]; // An array of graph scopes
90+
const callback = (errorDesc, token, error, tokenType) => {};
91+
// An Optional options for initializing the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics#configuration-options
8592
const options = {
86-
// An Optional options for initializing the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics#configuration-options
8793
redirectUri: "Your redirect URI",
8894
};
89-
const authProvider = new MSALAuthenticationProvider(clientId, scopes, options);
95+
const graphScopes = ["user.read", "mail.send"]; // An array of graph scopes
96+
97+
// Initialize the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics#initialization-of-msal
98+
const userAgentApplication = new UserAgentApplication(clientId, undefined, callback, options);
99+
const authProvider = new MSALAuthenticationProvider(userAgentApplication, scopes);
90100
```
91101

92102
User can integrate own preferred authentication library by implementing `IAuthenticationProvider` interface. Refer implementing [Custom Authentication Provider](./docs/CustomAuthenticationProvider.md).

0 commit comments

Comments
 (0)