---
title: "Microsoft 365 using OAuth 2.0 Device Code Flow authentication"
canonical: "https://docs.cuesystem.com/space/TOA/262176769/Microsoft%20365%20using%20OAuth%202.0%20Device%20Code%20Flow%20authentication"
format: markdown
---
This [method of authentication](https://cue.atlassian.net/wiki/spaces/M3SG/pages/284853099) is recommended for newly created systems. This authentication can be used in a hybrid environment where Active Directory Federation Service (AD FS) is used for user login. 

> ℹ️ For details on setting up in Microsoft 365, see the [Microsoft 365 Setup Guide](https://cue.atlassian.net/wiki/spaces/M3SG). In this manual under Setup procedure / Registered app creating, follow the procedure in [Other Connection Agents](https://cue.atlassian.net/wiki/spaces/M3SG/pages/806454250) / **Configuration For units / Device Code Flow.**

## Add server

- Add the Office 365 server to the configuration. Click "**Basic setup**" in the top bar and then click "**Servers**".

- The server settings screen opens. Click the "**Add**" button.
- In the "**Server type**" field, select "**Office 365 - Microsoft Graph App**".
- You can test the connection with the server by pressing "**Test**".
- Continue by tapping "**OK**".

## Add service account

- Now you need to add a service account. Click "**Basic setup**" in the top bar and then click "**Service accounts**".
- The service accounts settings screen opens. Click the "**Add**" button.
- In the "**Account type**" field, select "**Office 365 - Microsoft Graph App Device Code Flow**".
- In the "**User name**" field, enter the service account email (e.g. **touchone@contoso.com**), Directory ID, and Application ID.
- To verify the service account, click the "**Activate**" button.

> ⚠️ The following steps must be completed within 10 minutes.

- Copy the unique login code displayed in the window to your clipboard.
- Then open [https://microsoft.com/devicelogin](https://microsoft.com/devicelogin) in a new browser tab or click on the corresponding link on the page.
- On the Microsoft login page, copy the unique code and click "Next".
- Now you need to <span style="color: #bf2600">**log in**</span><span style="color: #bf2600"> with the account you entered in the service account settings.</span> <span style="color: #bf2600">**Be careful not to use your personal account that you usually use to log in to applications and that the browser may offer you. **</span>Click on the service account. If the browser does not offer you this account, select "Use another account" and then enter the service account email. If the browser insists on logging in with your standard account, we recommend using the anonymous/InPrivate browser mode to log in.
- In the next window, check or enter the **service account** and click "**Next**".
- Now enter your service account password and click "**Sign in**".
- If this is your **first time logging** in with this account and graph application, you will be prompted in the next window to enable necessary permissions. To grant permission click "Accept".
- Now a window with information about successful login appears. You can now close the Microsoft 365 login tab.
- Now **return to the touchONE-manager web interface** tab and wait a few seconds until you see the information about successful account activation.
- You can test your account by clicking the "**Test**" button.
- Click "OK" to complete the service account setup.

## Add room account

- Finally, you need to add a room account. Click on "Basic setup" in the top bar and then click "Rooms".
- The rooms settings screen opens. Click the "**Add**" button.
- In the "**Room email**" field enter room account email (e.g. **demoroom@cuesystem.com**).
- In the field "**Displayed room name**" you can enter the room name which will be shown on the touchONE panel.
- The server address and service account email are pre-entered in "**Server**" and "**Service account**".
- You can test the room account by tapping "**Test**".
- Save the account settings by clicking on "**OK**".

> ⚠️ Save all the settings by clicking the "Save" button in the upper right corner. This completes the basic setup of accounts for Microsoft 365.

You can now proceed with [Adding the reservation system units](https://cue.atlassian.net/wiki/spaces/TOA/pages/234193338).