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: CONTRIBUTING.md
+13-15
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,4 @@
1
-
Contribute to this documentation
2
-
3
-
Thank you for your interest in our documentation!
1
+
# Contributing
4
2
5
3
*[Ways to contribute](#ways-to-contribute)
6
4
*[Contribute using GitHub](#contribute-using-github)
@@ -101,10 +99,10 @@ To make the contribution process as seamless as possible, follow these steps.
101
99
102
100
#### To create a new branch
103
101
104
-
1.Open Git Bash.
105
-
2.At the Git Bash command prompt, type `git pull upstream master:<new branch name>`. This creates a new branch locally that is copied from the latest MicrosoftGraph master branch.
106
-
3.At the Git Bash command prompt, type `git push origin <new branch name>`. This alerts GitHub to the new branch. You should now see the new branch in your fork of the repository on GitHub.
107
-
4.At the Git Bash command prompt, type `git checkout <new branch name>` to switch to your new branch.
102
+
1.Open Git Bash.
103
+
2.At the Git Bash command prompt, type `git pull upstream master:<new branch name>`. This creates a new branch locally that is copied from the latest MicrosoftGraph master branch.
104
+
3.At the Git Bash command prompt, type `git push origin <new branch name>`. This alerts GitHub to the new branch. You should now see the new branch in your fork of the repository on GitHub.
105
+
4.At the Git Bash command prompt, type `git checkout <new branch name>` to switch to your new branch.
108
106
109
107
#### Add new content or edit existing content
110
108
@@ -117,7 +115,7 @@ The files in `C:\Users\<yourusername>\<repo name>` are a working copy of the new
117
115
git add .
118
116
git commit -v -a -m "<Describe the changes made in this commit>"
119
117
120
-
The `add` command adds your changes to a staging area in preparation for committing them to the repository. The period after the `add` command specifies that you want to stage all of the files that you added or modified, checking subfolders recursively. (If you don't want to commit all of the changes, you can add specific files. You can also undo a commit. For help, type `git add -help` or `git status`.)
118
+
The `add` command adds your changes to a staging area in preparation for committing them to the repository. The period after the `add` command specifies that you want to stage all of the files that you added or modified, checking sub folders recursively. (If you don't want to commit all of the changes, you can add specific files. You can also undo a commit. For help, type `git add -help` or `git status`.)
121
119
122
120
The `commit` command applies the staged changes to the repository. The switch `-m` means you are providing the commit comment in the command line. The -v and -a switches can be omitted. The -v switch is for verbose output from the command, and -a does what you already did with the add command.
123
121
@@ -129,13 +127,13 @@ When you're finished with your work and are ready to have it merged into the mai
129
127
130
128
#### To submit a pull request to the main repository
131
129
132
-
1.In the Git Bash command prompt, type `git push origin <new branch name>`. In your local repository, `origin` refers to your GitHub repository that you cloned the local repository from. This command pushes the current state of your new branch, including all commits made in the previous steps, to your GitHub fork.
133
-
2.On the GitHub site, navigate in your fork to the new branch.
134
-
3.Choose the **Pull Request** button at the top of the page.
135
-
4.Verify the Base branch is `microsoftgraph/<repo name>@master` and the Head branch is `<your username>/<repo name>@<branch name>`.
136
-
5.Choose the **Update Commit Range** button.
137
-
6.Add a title to your pull request, and describe all the changes you're making.
138
-
7.Submit the pull request.
130
+
1.In the Git Bash command prompt, type `git push origin <new branch name>`. In your local repository, `origin` refers to your GitHub repository that you cloned the local repository from. This command pushes the current state of your new branch, including all commits made in the previous steps, to your GitHub fork.
131
+
2.On the GitHub site, navigate in your fork to the new branch.
132
+
3.Choose the **Pull Request** button at the top of the page.
133
+
4.Verify the Base branch is `microsoftgraph/<repo name>@master` and the Head branch is `<your username>/<repo name>@<branch name>`.
134
+
5.Choose the **Update Commit Range** button.
135
+
6.Add a title to your pull request, and describe all the changes you're making.
136
+
7.Submit the pull request.
139
137
140
138
One of the site administrators will process your pull request. Your pull request will surface on the microsoftgraph/<reponame> site under Issues. When the pull request is accepted, the issue will be resolved.
In case your environment have support for or have polyfill 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)] and [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)], import `./node_modules/@microsoft/microsoft-graph-client/lib/src/core/index` into your module which doesn't have polyfills for these.
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)] and [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 can polyfill them and include as above or you can use [lib/graph-js-sdk-web.js](./lib/graph-js-sdk-web.js) which includes polyfills.
### 2. Authenticate for the Microsoft Graph service
43
61
44
62
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 have to include it externally (For including MSAL, refer [this](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-core#installation)).
45
-
Creating an instance of MSALAuthenticationProvider,
63
+
64
+
> **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).
65
+
66
+
#### Creating an instance of MSALAuthenticationProvider in browser environment
67
+
68
+
Refer devDependencies in [package.json](./package.json) for the compatible msal version and update that version in below.
const clientID ='your_client_id'; // Client Id of the registered application
76
+
const graphScopes = ["user.read", "mail.send"]; // An array of graph scopes
77
+
const options = { // An Optional options for initializing the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics#configuration-options
const clientID ='your_client_id'; // Client Id of the registered application
49
95
const graphScopes = ["user.read", "mail.send"]; // An array of graph scopes
50
96
const options = { // An Optional options for initializing the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics#configuration-options
@@ -53,26 +99,40 @@ const options = { // An Optional options for initializing the MSAL @see https://
User can integrate own preferred authentication library by implementing `IAuthenticationProvider` interface.
102
+
User can integrate own preferred authentication library by implementing `IAuthenticationProvider` interface. Refer implementing [Custom Authentication Provider](./docs/CustomAuthenticationProvider.md).
57
103
58
104
### 3. Initialize a Microsoft Graph Client object with an authentication provider
59
105
60
-
An instance of the **Client** class handles requests to Microsoft Graph API and processing the responses. To create a new instance of this class, you need to provide an instance of [`IAuthenticationProvider`](src/IAuthenticationProvider.ts) which needs to be passed as a value for `authProvider` key in [`Options`](src/IOptions.ts) to a static initializer method `Client.init`.
106
+
An instance of the **Client** class handles requests to Microsoft Graph API and processing the responses. To create a new instance of this class, you need to provide an instance of [`IAuthenticationProvider`](src/IAuthenticationProvider.ts) which needs to be passed as a value for `authProvider` key in [`ClientOptions`](src/IClientOptions.ts) to a static initializer method `Client.initWithMiddleware`.
107
+
108
+
#### For browser environment
109
+
110
+
```typescript
111
+
const options = {
112
+
authProvider// An instance created from previous step
For more information on initializing client, refer [this](./docs/CreatingClientInstance.md).
129
+
For more information on initializing client, refer [this document](./docs/CreatingClientInstance.md).
70
130
71
131
### 4. Make requests to the graph
72
132
73
-
Once you have authentication setup and an instance of Client, you can begin to make calls to the service. All requests should be start with `client.api(path)` and end with an action.
133
+
Once you have authentication setup and an instance of Client, you can begin to make calls to the service. All requests should be start with `client.api(path)` and end with an [action](./docs/Actions.md).
74
134
75
-
Getting user details,
135
+
Getting user details
76
136
77
137
```typescript
78
138
try {
@@ -143,4 +203,4 @@ This project has adopted the [Microsoft Open Source Code of Conduct](https://ope
143
203
144
204
## Third Party Notices
145
205
146
-
See [Third Party Notices](https://github.com/microsoftgraph/msgraph-sdk-javascript/blob/master/THIRD%20PARTY%20NOTICES) for information on the packages that are included in the [package.json](https://github.com/microsoftgraph/msgraph-sdk-javascript/blob/master/package.json)
206
+
See [Third Party Notices](./THIRD%20PARTY%20NOTICES) for information on the packages that are included in the [package.json](./package.json)
Copy file name to clipboardExpand all lines: docs/CreatingClientInstance.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ Initialization of the Client can be done in one of below two ways
6
6
7
7
In order to instantiate a Client object, one has to pass in the `authProvider` or `middleware` chain in [ClientOptions](../src/IClientOptions.ts).
8
8
9
-
### 1. Default Middleware chain
9
+
### Option A. Default Middleware chain
10
10
11
11
Pass an instance of a class which implementing [AuthenticationProvider](../src/IAuthenticationProvider.ts) interface as `authProvider` in [ClientOptions](../src/IClientOptions.ts), which will instantiate the Client with default set of middleware chain.
Copy file name to clipboardExpand all lines: docs/CustomMiddlewareChain.md
+5-4
Original file line number
Diff line number
Diff line change
@@ -8,12 +8,10 @@ As name suggests it comes in middle of something and that is request and respons
8
8
9
9
### Implement Middlewares
10
10
11
-
Create own set of middlewares by implementing [Middleware](../src/IMiddleware.ts) interface. Here two middlewares are created one for handling Logging and another for handling http request and response.
11
+
Create a custom middleware pipeline by implementing the [Middleware](../src/IMiddleware.ts) interface. The following examples demonstrate how to create a custom logging middleware and how to create a custom http request a response handler.
12
12
13
13
First middleware is passed with the context object containing request, and other middleware specific options. One has to explicitly make call to execute method of the next middleware with context object once the current middleware work is over.
14
14
15
-
NOTE: Http message handler should set the response object in the context object.
**Save request to get the raw response before calling action**
15
-
16
-
The graph request will be returned for all the method calls except for actions, because they makes call to the server, so have to save the copy of graph request instance before calling actions
0 commit comments