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
+5-54
Original file line number
Diff line number
Diff line change
@@ -55,64 +55,15 @@ Register your application to use Microsoft Graph API using one of the following
55
55
56
56
### 2. Authenticate for the Microsoft Graph service
57
57
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)).
58
+
The Microsoft Graph JavaScript Client Library has an adapter implementation for the following -
59
59
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).
60
+
- ([TokenCredentialAuthenticationProvider](src/authentication/TokenCredentialAuthenticationProvider.ts)) to support [Azure Identity TokenCredential](https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/identity/identity/README.md) (Azure Identity client library for JavaScript) which takes care of getting the `accessToken`. @azure/identity library does not ship with this library, user has to include it externally (For including @azure/identity, refer [this](https://www.npmjs.com/package/@azure/identity)).
61
61
62
-
#### Creating an instance of ImplicitMSALAuthenticationProvider in browser environment
62
+
> Learn how to [create an instance of TokenCredentialAuthenticationProvider](./docs/TokenCredentialAuthenticationProvider.md).
63
63
64
-
Refer devDependencies in [package.json](./package.json) for the compatible msal version and update that version in below.
64
+
- ([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)).
// An Optional options for initializing the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics#configuration-options
102
-
const msalConfig = {
103
-
auth: {
104
-
clientId: "your_client_id", // Client Id of the registered application
105
-
redirectUri: "your_redirect_uri",
106
-
},
107
-
};
108
-
const graphScopes = ["user.read", "mail.send"]; // An array of graph scopes
109
-
110
-
// Important Note: This library implements loginPopup and acquireTokenPopup flow, remember this while initializing the msal
111
-
// Initialize the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js#1-instantiate-the-useragentapplication
> Learn how to [create an instance of ImplicitMSALAuthenticationProvider](./docs/ImplicitMSALAuthenticationProvider.md).
116
67
117
68
User can integrate own preferred authentication library by implementing `IAuthenticationProvider` interface. Refer implementing [Custom Authentication Provider](./docs/CustomAuthenticationProvider.md).
The authProviderOptions/ folders contains barrels for exporting Authentication Provider options such as MSAL and Azure Identity Token Credentials.
2
+
3
+
[tsconfig-sub-cjs.json](../tsconfig-sub-es.json) and [tsconfig-sub-cjs.json](../tsconfig-sub-es.json) contains the config for transpiling the files to authProviders/ output folder.
4
+
5
+
This approach is used because of the limitations of creating a submodule structure - References - https://github.com/microsoft/TypeScript/issues/8305https://github.com/microsoft/TypeScript/issues/33079
#### Creating an instance of ImplicitMSALAuthenticationProvider in browser environment
2
+
3
+
Refer devDependencies in [package.json](../package.json) for the compatible msal version and update that version in below.
4
+
5
+
**Important Note:** MSAL is supported only for frontend applications, for server-side authentication you either can use [TokenCredentialAuthenticationProvider](./TokenCredentialAuthenticationProvider.md) or implement your own AuthenticationProvider. Learn how you can create a [Custom Authentication Provider](./docs/CustomAuthenticationProvider.md).
// An Optional options for initializing the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics#configuration-options
42
+
const msalConfig = {
43
+
auth: {
44
+
clientId: "your_client_id", // Client Id of the registered application
45
+
redirectUri: "your_redirect_uri",
46
+
},
47
+
};
48
+
const graphScopes = ["user.read", "mail.send"]; // An array of graph scopes
49
+
50
+
// Important Note: This library implements loginPopup and acquireTokenPopup flow, remember this while initializing the msal
51
+
52
+
// Initialize the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js#1-instantiate-the-useragentapplication
#### Creating an instance of TokenCredentialAuthentication
2
+
3
+
###### Links for more information -
4
+
5
+
-[GitHub - Azure Identity client library for JavaScript ](https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/identity/identity/README.md)
6
+
7
+
-[npm - Azure Identity client library for JavaScript](https://www.npmjs.com/package/@azure/identity)
8
+
9
+
- Check the [tokenCredentialSamples folder][../samples/tokencredentialsamples]. The ClientSecretCredentialFlow is an example of using TokenCredential to authenticate a node application. The AuthenticationCodeFlow is an example of using TokenCredential to authenticate a browser application.
10
+
11
+
**Important Note:** TokenCredentials can be used to authenticate browser and node applications.
12
+
13
+
###### Example of how to create and pass a token credential -
14
+
15
+
```typescript
16
+
// Import the TokenCredential class that you wish to use. This example uses a Client SecretCredential
// Set your scopes and options for TokenCredential.getToken (Check the ` interface GetTokenOptions` in (TokenCredential Implementation)[https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/core/core-auth/src/tokenCredential.ts])
// Set your scopes and options for TokenCredential.getToken (Check the ` interface GetTokenOptions` in (TokenCredential Implementation)[https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/core/core-auth/src/tokenCredential.ts])
0 commit comments