Skip to content

Commit 7da0d9f

Browse files
committed
refactoring with error conditions and test merge
1 parent a7e1a62 commit 7da0d9f

File tree

11 files changed

+1750
-449
lines changed

11 files changed

+1750
-449
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,13 @@ npm-debug.log
1414
/lib/*
1515
!/lib/.npmignore
1616

17-
<<<<<<< HEAD
1817
/authProviders/*
1918

2019
src/**/*.js
2120
src/**/*.js.map
2221
src/**/*.d.ts
2322

2423
samples/**/*/secrets.ts
25-
=======
26-
>>>>>>> 3.0.0
2724
samples/node/secrets.json
2825
samples/browser/src/secrets.js
2926
samples/browser/src/graph-js-sdk.js

README.md

Lines changed: 5 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -55,68 +55,15 @@ Register your application to use Microsoft Graph API using one of the following
5555

5656
### 2. Authenticate for the Microsoft Graph service
5757

58-
The Microsoft Graph JavaScript Client Library has an adapter implementation for the following - \* ([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)). > Learn how to [create an instance of TokenCredentialAuthenticationProvider](./docs/TokenCredentialAuthenticationProvider.md)
58+
The Microsoft Graph JavaScript Client Library has an adapter implementation for the following -
5959

60-
* ([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)).
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)).
6161

62-
> Learn how to [create an instance of ImplicitMSALAuthenticationProvider](./docs/ImplicitMSALAuthenticationProvider.md)
62+
> Learn how to [create an instance of TokenCredentialAuthenticationProvider](./docs/TokenCredentialAuthenticationProvider.md).
6363
64-
<<<<<<< HEAD
65-
> **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).
66-
=======
67-
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)).
6865

69-
```html
70-
<script src="https://secure.aadcdn.microsoftonline-p.com/lib/<version>/js/msal.min.js"></script>
71-
```
72-
73-
```typescript
74-
// Configuration options for MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL.js-1.0.0-api-release#configuration-options
75-
const msalConfig = {
76-
auth: {
77-
clientId: "your_client_id", // Client Id of the registered application
78-
redirectUri: "your_redirect_uri",
79-
},
80-
};
81-
const graphScopes = ["user.read", "mail.send"]; // An array of graph scopes
82-
83-
// Important Note: This library implements loginPopup and acquireTokenPopup flow, remember this while initializing the msal
84-
// Initialize the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js#1-instantiate-the-useragentapplication
85-
const msalApplication = new Msal.UserAgentApplication(msalConfig);
86-
const options = new MicrosoftGraph.MSALAuthenticationProviderOptions(graphScopes);
87-
const authProvider = new MicrosoftGraph.ImplicitMSALAuthenticationProvider(msalApplication, options);
88-
```
89-
90-
#### Creating an instance of ImplicitMSALAuthenticationProvider in node environment
91-
92-
Refer devDependencies in [package.json](./package.json) for the compatible msal version and update that version in below.
93-
94-
```cmd
95-
npm install msal@<version>
96-
```
97-
98-
```typescript
99-
import { UserAgentApplication } from "msal";
100-
101-
import { ImplicitMSALAuthenticationProvider } from "@microsoft/microsoft-graph-client/lib/src/ImplicitMSALAuthenticationProvider";
102-
import { MSALAuthenticationProviderOptions } from "@microsoft/microsoft-graph-client/lib/src/MSALAuthenticationProviderOptions";
103-
104-
// An Optional options for initializing the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics#configuration-options
105-
const msalConfig = {
106-
auth: {
107-
clientId: "your_client_id", // Client Id of the registered application
108-
redirectUri: "your_redirect_uri",
109-
},
110-
};
111-
const graphScopes = ["user.read", "mail.send"]; // An array of graph scopes
112-
113-
// Important Note: This library implements loginPopup and acquireTokenPopup flow, remember this while initializing the msal
114-
// Initialize the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js#1-instantiate-the-useragentapplication
115-
const msalApplication = new UserAgentApplication(msalConfig);
116-
const options = new MSALAuthenticationProviderOptions(graphScopes);
117-
const authProvider = new ImplicitMSALAuthenticationProvider(msalApplication, options);
118-
```
119-
>>>>>>> 3.0.0
66+
> Learn how to [create an instance of ImplicitMSALAuthenticationProvider](./docs/ImplicitMSALAuthenticationProvider.md).
12067
12168
User can integrate own preferred authentication library by implementing `IAuthenticationProvider` interface. Refer implementing [Custom Authentication Provider](./docs/CustomAuthenticationProvider.md).
12269

docs/ImplicitMSALAuthenticationProvider.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Refer devDependencies in [package.json](../package.json) for the compatible msal version and update that version in below.
44

5+
**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).
6+
57
```html
68
<script src="https://secure.aadcdn.microsoftonline-p.com/lib/<version>/js/msal.min.js"></script>
79
```
@@ -34,7 +36,7 @@ npm install msal@<version>
3436
```typescript
3537
import { UserAgentApplication } from "msal";
3638

37-
import { ImplicitMSALAuthenticationProvider } from "@microsoft/microsoft-graph-client/lib/src/ImplicitMSALAuthenticationProvider";
39+
import { ImplicitMSALAuthenticationProvider } from "@microsoft/microsoft-graph-client/lib/src/authentication/ImplicitMSALAuthenticationProvider";
3840
import { MSALAuthenticationProviderOptions } from "@microsoft/microsoft-graph-client/lib/src/MSALAuthenticationProviderOptions";
3941

4042
// An Optional options for initializing the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics#configuration-options

0 commit comments

Comments
 (0)