> For the complete documentation index, see [llms.txt](https://docs.wem.io/platform/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wem.io/platform/wemtipsandtricks/integration/office365-integration.md).

# Office365 Integration

Office365 offers many services that we can integrate with. E.g.:

1. Outlook
2. Calendar
3. OneDrive

We’ve created a template project where you can begin using the Office365 API. In this guide we’ll show you how to set it up.

### The OAuth 2.0 authentication protocol <a href="#the-oauth-2.0-authentication-protocol" id="the-oauth-2.0-authentication-protocol"></a>

To be able to safely make use of external providers there’s always some authentication procedure involved. The WEM Modeler already supports the two main standard industry protocols, SAML 2.0 and OAuth 2.0.

In this guide we’ll be using the OAuth 2.0 protocol. Below is a little bit of technical protocol information that helps you understand the actual integration.\
The OAuth 2.0 protocol requires 5 pieces of information to work properly:

1. An Authorization Endpoint, a link where we’ll redirect to when we start the authentication procedure.
2. A Token Endpoint, a link which will give us an access token after we’ve successfully validated ourselves with the ‘Authorization Endpoint’.
3. A Client ID, this will validate our application to the external service provider.
4. A Client Secret, this will also validate our application to the external service provider.
5. Redirect URLs, after successfully logging into the external service we’ll be redirected to these URLs.![](https://wem.io/wp-content/uploads/2018/12/app-protocol-flow.png)

After retrieving the access token we’ll be able to use the external service provider’s API.

(An API, application programming interface, is like a toolbox that grants us access to a bunch of useful functions. For example, Outlook’s API allows you to retrieve all your unread mails.)

### Step 1 – Copy the example project <a href="#step-1--copy-the-example-project" id="step-1--copy-the-example-project"></a>

![](https://wem.io/wp-content/uploads/2018/12/0.png)

Log into your WEM account at [https://my.wem.io](https://my.wem.io/) and scroll down to ‘WEM Example projects’. There you’ll find the example project ‘Office 365 Template’, click on the `Copy` button. Afterwards go to [https://modeler.wem.io](https://modeler.wem.io/), and open the newly copied project.

### Step 2 – Setting up the project (optional) <a href="#step-2--setting-up-the-project-optional" id="step-2--setting-up-the-project-optional"></a>

Let’s say we end up working on our project for a long time.\
Then it would be nice if we could publish the project right?\
To be able to do this we first need to link a domain address with our project.

![](https://wem.io/wp-content/uploads/2018/12/7.png)

Go to the ‘Project settings’ and configure the hostnames for the staging and live environment. (If the hostname isn’t taken, you can generally use the name of your project and the postfix “.staging.wem.io” or “.live.wem.io” as hostnames.) And with that our hostnames are set up. Don’t forget to save the changes you’ve made!

![](https://wem.io/wp-content/uploads/2018/12/add-hostname-save.png)

### Step 3 – Getting your redirect URLs <a href="#step-3--getting-your-redirect-urls" id="step-3--getting-your-redirect-urls"></a>

![](https://wem.io/wp-content/uploads/2018/12/22.png)

Click on the authentication provider `Office 365`.

![](https://wem.io/images/content/public/tips-and-tricks/integration/office365/23.png)

Copy and write all the `Redirect URLs` down somewhere. The redirect URLs in our case are:

1. <https://preview.wem.io/4639/auth/oauth2/office-365>
2. <https://office.staging.wem.io/auth/oauth2/office-365>
3. <https://office.live.wem.io/auth/oauth2/office-365>

### Step 4 – Creating your Microsoft Azure App <a href="#step-4--creating-your-microsoft-azure-app" id="step-4--creating-your-microsoft-azure-app"></a>

Go to [https://portal.azure.com](https://portal.azure.com/) and log into your Office365 account. (If you do not have an Office365 account you can get a free trial at <https://products.office.com/en/try>)

![](https://wem.io/wp-content/uploads/2018/12/26.png)

Click on `Azure Active Directory` and after that click on `App registrations`.

![](https://wem.io/wp-content/uploads/2018/12/3.png)

Click on the button `New application registration` and fill in the form that pops up.

![](https://wem.io/wp-content/uploads/2018/12/4.png)

In the text field `Name` you can enter any name you prefer. In the field `Application type` you need to select the option `Web app / API`. In the field `Sign-on URL` you can enter any URL you prefer, it doesn’t matter which URL you enter.

![](https://wem.io/wp-content/uploads/2018/12/5.png)

In the next screen you can see some of the settings of your application. Write down the ‘Application ID’, that will be your client id. After that’s done click on the `Settings` button.

### Step 5 – Entering the Redirect URLs <a href="#step-5---entering-the-redirect-urls" id="step-5---entering-the-redirect-urls"></a>

![](https://wem.io/wp-content/uploads/2018/12/25.png)

Afterwards click on the `Reply URLs` button.

![](https://wem.io/wp-content/uploads/2018/12/9.png)

Enter the `Redirect URLs` you’ve written down before, and press the `Save` button afterwards.

### Step 6 – Creating a client secret <a href="#step-6--creating-a-client-secret" id="step-6--creating-a-client-secret"></a>

![](https://wem.io/wp-content/uploads/2018/12/25.png)

Click on the ‘Keys’ button.

![](https://wem.io/wp-content/uploads/2018/12/10.png)

Enter a new password. Write in the `Description` field any name you prefer, we choose `Client Secret`. Select in the `Expires` field the option `Never expires`.

After that’s done click on the `Save` button. The actual key will now appear in the `Value` field.

![](https://wem.io/wp-content/uploads/2018/12/11.png)

Write the key down somewhere, that is our client secret.

### Step 7 – Selecting the permissions of the app <a href="#step-7--selecting-the-permissions-of-the-app" id="step-7--selecting-the-permissions-of-the-app"></a>

![](https://wem.io/wp-content/uploads/2018/12/25.png)

Click on the `required permissions` button.

![](https://wem.io/wp-content/uploads/2018/12/12.png)

Click on the `Add` button.

![](https://wem.io/wp-content/uploads/2018/12/13.png)

Select the `Microsoft Graph` API.

![](https://wem.io/wp-content/uploads/2018/12/14.png)

Select all the permissions, this way we aren’t restricted in the way we’ll use the app.

![](https://wem.io/wp-content/uploads/2018/12/15.png)

After that’s done, do not forget to click the `Grant Permissions` button.

### Step 8 – Get the OAuth2.0 endpoints <a href="#step-8--get-the-oauth2.0-endpoints" id="step-8--get-the-oauth2.0-endpoints"></a>

![](https://wem.io/wp-content/uploads/2018/12/26.png)

Go to the `App registrations` overview.

![](https://wem.io/wp-content/uploads/2018/12/16.png)

Click on the `Endpoints` button.

![](https://wem.io/wp-content/uploads/2018/12/17.png)

Write down the OAuth 2.0 endpoints somewhere.

1. <https://login.microsoftonline.com/e2671fe1-61d1-41c2-bbbf-06440825adea/oauth2/token>
2. <https://login.microsoftonline.com/e2671fe1-61d1-41c2-bbbf-06440825adea/oauth2/authorize>

For our purposes we need to change the endpoints a little bit, since we’ll be using the 2.0 version of the API. In both URLs add after ‘oauth2/’ the text ‘v2.0/’. The URLs will now look like this:

1. <https://login.microsoftonline.com/e2671fe1-61d1-41c2-bbbf-06440825adea/oauth2/v2.0/token>
2. <https://login.microsoftonline.com/e2671fe1-61d1-41c2-bbbf-06440825adea/oauth2/v2.0/authorize>

### Step 9 – Setting up the authentication provider <a href="#step-9--setting-up-the-authentication-provider" id="step-9--setting-up-the-authentication-provider"></a>

![](https://wem.io/wp-content/uploads/2018/12/22.png)

Click on the ‘Office 365’ Authentication provider.

![](https://wem.io/wp-content/uploads/2018/12/18.png)

Write your Client ID and Client Secret in these fields. You’ve written them down in step 4 and step 6.

![](https://wem.io/wp-content/uploads/2018/12/19.png)

Write down the appropriate URLs in the ‘Authorization Endpoint’ field and the ‘Token Endpoint’ field. You’ve written them down in step 8. Under the ‘Scope’ field you need to write down ‘mail.read’, what you write down in this field is not that important as long as we do not leave it empty. And with that your authentication provider is done!

### Step 10 – Trying out the template project <a href="#step-10--trying-out-the-template-project" id="step-10--trying-out-the-template-project"></a>

The template project can now be used.

![](https://wem.io/wp-content/uploads/2018/12/20.png)

Click on the highlighted ‘Preview’ button to try out the template project! It’s recommended to look through all the flowcharts in the project to see how it all works.

If you want to know more about the Office 365 API visit <https://developer.microsoft.com/en-us/graph/docs>.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.wem.io/platform/wemtipsandtricks/integration/office365-integration.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
