# Input need for integration with Microsoft Graph Api - authentication flow

**URL:** <https://community.homey.app/t/input-need-for-integration-with-microsoft-graph-api-authentication-flow/101826>\
**Category:** Developers\
**Created:** [January 21, 2024, 9:31am UTC](https://community.homey.app/t/input-need-for-integration-with-microsoft-graph-api-authentication-flow/101826 "2024-01-21T09:31:40Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kim\_Kokholm](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/kim_kokholm/32/91519_2.png) [@Kim\_Kokholm](https://community.homey.app/u/Kim_Kokholm)\
**Post date:** [January 21, 2024, 9:31am UTC](https://community.homey.app/t/input-need-for-integration-with-microsoft-graph-api-authentication-flow/101826/1 "2024-01-21T09:31:40Z")

</div>

Hi fellow developers.

I am doing an app, where I want to integrate with Microsoft To Do. I’m developing an app with a card to create a task to a provided list. I really like Microsoft To Do and want to integrate with flows and think its useful for others as well.  
Perhaps in the future, I want to integrate with Microsoft Teams as well.

Microsoft To Do, and Teams, a Microsoft account is required. Microsoft personal account is what this app will support.  
To integrate with Microsoft To Do - one way is to use Graph Api.

The following flow is required:

1. Authenticate with Microsoft Identity

- Register an app in Azure Entra Directory (generic Homey-app on “my account”)
- Setup permissions for this app to specific Graph Api (in this case Tasks.ReadWrite)
- Trigger authentication flow from Homey-app to “concent” the logged in user ( **A** )
  - The user will have to accept that Homey-app will access Tasks etc. - in a popup.

1. Integration with Microsoft To Do

- From the homey app, call [Login.microsoft.com](http://Login.microsoft.com) and get a Bearer token in return, use this bearer token for further Graph Api actions.
  - To do so, the login-call must be provided with a “secret” wich is setup in App Registration

`My findings so far`  
**A** I am able to do a partial authentication in a popup, by trigger a popup:  
`https://login.microsoftonline.com/consumers/oauth2/v2.0/authorize?client_id=${clientId}&response_type=code&redirect_uri=https%3A%2F%2Flogin.microsoftonline.com%2Fcommon%2Foauth2%2Fnativeclient&response_mode=query&scope=api%3A%2F%2F6a90c318-a2c5-42fb-8a76-d4b03d25f8e7/TODO&state=My8evpyCmsouwMwb`;

Most flows, ends with a callback. This callback calls your backend and is exposed by web. But with Homey I do not think it is possible to expose a callback url - also running a Homey app inside a node/container does not have a direct url for external services to call.

I know the description for this is kinda messy, have been struggling with this for while now and quite confused atm.  
I’ve done Microsoft Authentication before, but inside Azure with msal and a lot of this is “automatic”. But with Homey-App and simple http-client - I’m struggling here 🙂

`Remarks`  
I know this can be achieved, I’ve seen it done in like Tesla App and also the Discord App.  
But I’ve found very little information about doing so, so maybe one of you, in this community, have a solution or input needed for me to complete this authentication flow.

Also from the description in Homey Cli, the optimal way is to make a repair option, but then I will have to provide own html pages, which I dont have a template to. Maybe someone can provide a template for this.

`What am I looking for`  
Someone who can explain how this can be achieved. Also I could be missing a piece, in the puzzle, where the authentication flow, will provide me with a personal token or somehing to provide to the Microsoft Identity, that identifies the user X so that I can target that specific Microsoft-account.  
(from a cookie or something…)

Again, sorry for this fuzzy description, but doing the Tasks operation is super simple - the authentication is a mf’er 🙂  
Looking forward to your input or guide me in the right direction maby.

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [January 21, 2024, 9:47am UTC](https://community.homey.app/t/input-need-for-integration-with-microsoft-graph-api-authentication-flow/101826/2 "2024-01-21T09:47:16Z")

</div>

If the auth is using oAuth2, then the Athom oAuth module is a good base.  
It covers the whole auth and token handling.  
You need to add thin node module to your app. Follow the documentation and the examples on Github.

> **[OAuth2](https://apps.developer.homey.app/cloud/oauth2)**
>
> Authorise Homey to use a Web API with OAuth2.

---

<div class="post-metadata">

**Author:** ![Kim\_Kokholm](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/kim_kokholm/32/91519_2.png) [@Kim\_Kokholm](https://community.homey.app/u/Kim_Kokholm)\
**Post date:** [January 21, 2024, 10:15am UTC](https://community.homey.app/t/input-need-for-integration-with-microsoft-graph-api-authentication-flow/101826/3 "2024-01-21T10:15:11Z")

</div>

Thank you for the input, I will look into this.  
Don’t know why I didn’t dig further into this, maybe it was because I thought i was for Homey-logins only.

---

<div class="post-metadata">

**Author:** ![Kim\_Kokholm](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/kim_kokholm/32/91519_2.png) [@Kim\_Kokholm](https://community.homey.app/u/Kim_Kokholm)\
**Post date:** [January 21, 2024, 11:10pm UTC](https://community.homey.app/t/input-need-for-integration-with-microsoft-graph-api-authentication-flow/101826/4 "2024-01-21T23:10:34Z")

</div>

Hi @RonnyW , thank you for your input. I’ve managed to get this thing working.  
I ran into a lot of different issues and variants - kept pushing 🙂

I will delete this thread. Thank you for your input.

---

<div class="post-metadata">

**Author:** ![Kim\_Kokholm](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/kim_kokholm/32/91519_2.png) [@Kim\_Kokholm](https://community.homey.app/u/Kim_Kokholm)\
**Post date:** [January 21, 2024, 11:12pm UTC](https://community.homey.app/t/input-need-for-integration-with-microsoft-graph-api-authentication-flow/101826/5 "2024-01-21T23:12:38Z")

</div>

On the other hand, I don’t know how to delete this topic.

---

<div class="post-metadata">

**Author:** ![Didier\_SmartHome](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/didier_smarthome/32/97365_2.png) [@Didier\_SmartHome](https://community.homey.app/u/Didier_SmartHome)\
**Post date:** [January 22, 2024, 9:19am UTC](https://community.homey.app/t/input-need-for-integration-with-microsoft-graph-api-authentication-flow/101826/6 "2024-01-22T09:19:56Z")

</div>

@Kim_Kokholm Looking forward for your app for Microsoft To Do and maybe Teams latter on. I use them both extensively…

---

<div class="post-metadata">

**Author:** ![Kim\_Kokholm](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/kim_kokholm/32/91519_2.png) [@Kim\_Kokholm](https://community.homey.app/u/Kim_Kokholm)\
**Post date:** [January 22, 2024, 10:41am UTC](https://community.homey.app/t/input-need-for-integration-with-microsoft-graph-api-authentication-flow/101826/7 "2024-01-22T10:41:48Z")

</div>

@Didier_SmartHome  
The app is live:

> [@\[APP\]\[PRO\] Microsoft To Do](https://community.homey.app/t/app-pro-microsoft-to-do/101947):
>
> Hi all Microsoft To Do is now available in app store. Install the app. Add device: Microsoft To Do. Sign-in/Authenticate with Microsoft account. Select your account. Add card to flow where you name the task you want to add and then select the list of which the task will be added. This app is for personal accounts. Maybe organization-accounts are supported as well (you tell me). Microsoft To Do is an awesome app for both desktop and mobile. Please bring feature requests or constructive feed…

I’m also a (fellow) fan of To Do.

---

<div class="post-metadata">

**Author:** ![Didier\_SmartHome](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/didier_smarthome/32/97365_2.png) [@Didier\_SmartHome](https://community.homey.app/u/Didier_SmartHome)\
**Post date:** [January 22, 2024, 11:08am UTC](https://community.homey.app/t/input-need-for-integration-with-microsoft-graph-api-authentication-flow/101826/8 "2024-01-22T11:08:40Z")

</div>

Great. I’ll try that later today. FYI your link is either private or inaccessible. I could access it with [Microsoft To Do App for Homey | Homey](https://homey.app/en-us/app/com.microsoft.todo/Microsoft-To-Do/)
