# How to use Keycloak as an identity provider with Office365 and login to applications like PowerApps

**URL:** <https://forum.keycloak.org/t/how-to-use-keycloak-as-an-identity-provider-with-office365-and-login-to-applications-like-powerapps/18080>\
**Category:** Getting advice\
**Tags:** authentication\
**Created:** [October 24, 2022, 10:42am UTC](https://forum.keycloak.org/t/how-to-use-keycloak-as-an-identity-provider-with-office365-and-login-to-applications-like-powerapps/18080 "2022-10-24T10:42:06Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![MatthiasB](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@MatthiasB](https://forum.keycloak.org/u/MatthiasB)\
**Post date:** [October 24, 2022, 10:42am UTC](https://forum.keycloak.org/t/how-to-use-keycloak-as-an-identity-provider-with-office365-and-login-to-applications-like-powerapps/18080/1 "2022-10-24T10:42:06Z")

</div>

Hello together,

I need to connect my Keycloak Server to Office365, but it needs to be the current Identity Provider and not Office365.

In my scenario a user login via KeyCloak and then the question is going to O365 and then coming back and the user can use all the things like Login to SharePoint or PowerAutomate.

I found some advice for Office365, but not the other way round. Do the user need to be in Azure AD, when he/she is authenticating via KeyCloak?

Maybe you can help me! Thanks in advance!

Best regards

Matthias

---

<div class="post-metadata">

**Author:** ![weltonrodrigo](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/weltonrodrigo/32/3104_2.png) [@weltonrodrigo](https://forum.keycloak.org/u/weltonrodrigo)\
**Post date:** [October 24, 2022, 5:48pm UTC](https://forum.keycloak.org/t/how-to-use-keycloak-as-an-identity-provider-with-office365-and-login-to-applications-like-powerapps/18080/2 "2022-10-24T17:48:07Z")

</div>

I’m not that very familiar with office365, but I’m quite sure microsoft demands azure AD as primary authenticator, with the option to use an external identity provider, but only for external users (invitees).

That means you can add users to your Azure AD with their own company email and credentials. Example:

- Your azure ad domain is [abc.com](http://abc.com), Your users from [abc.com](http://abc.com) domain login via Azure AD
- You have a business partner Bob ([bob@jones.com](mailto:bob@jones.com)) who you need to invite into a teams groups for collaboration. You add [bob@jones.com](mailto:bob@jones.com) as an external user.
- You set up an external identity provider using SAML (or google or facebook) for [jones.com](http://jones.com)

Now when Bob needs to access the Teams group, he goes to [teams.microsoft.com](http://teams.microsoft.com), enter his e-mail, microsoft detects that a user exists for him in your tenant and offers Bob the option to log into [abc.com](http://abc.com) using his SAML provider (the jones.com`s keycloak).

For all I know, you cannot configure [abc.com](http://abc.com) users to login into office 365 using an external provider, you’d have sync the users to Azure AD somehow.

---

<div class="post-metadata">

**Author:** ![MatthiasB](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@MatthiasB](https://forum.keycloak.org/u/MatthiasB)\
**Post date:** [October 27, 2022, 7:10pm UTC](https://forum.keycloak.org/t/how-to-use-keycloak-as-an-identity-provider-with-office365-and-login-to-applications-like-powerapps/18080/3 "2022-10-27T19:10:51Z")

</div>

Thanks for the answer. If only that is possible. My idea that the user logs in into Keycloak with the Office365 credentials and then the user should redirected to a specific url. Is that possible?

e.g. Laura logs in into Keycloak and KeyCloak imports the user. Then she needs to be redirected to PowerApps.

Best regards  
Matthias

---

<div class="post-metadata">

**Author:** ![bwatkins79](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/bwatkins79/32/8163_2.png) [@bwatkins79](https://forum.keycloak.org/u/bwatkins79)\
**Post date:** [April 3, 2023, 8:57pm UTC](https://forum.keycloak.org/t/how-to-use-keycloak-as-an-identity-provider-with-office365-and-login-to-applications-like-powerapps/18080/4 "2023-04-03T20:57:29Z")

</div>

I have login with Keycloak and Office365 working if you still need help, let me know.

---

<div class="post-metadata">

**Author:** ![csed](https://avatars.discourse-cdn.com/v4/letter/c/5f9b8f/32.png) [@csed](https://forum.keycloak.org/u/csed)\
**Post date:** [April 12, 2023, 10:38am UTC](https://forum.keycloak.org/t/how-to-use-keycloak-as-an-identity-provider-with-office365-and-login-to-applications-like-powerapps/18080/5 "2023-04-12T10:38:34Z")

</div>

Yes please, appreciate any guidance in this, since it seems we are a bit stuck and earlier threads on the subject apparently have partly outdated information.  
Best regards  
Charles

---

<div class="post-metadata">

**Author:** ![Falconizer](https://avatars.discourse-cdn.com/v4/letter/f/b487fb/32.png) [@Falconizer](https://forum.keycloak.org/u/Falconizer)\
**Post date:** [April 12, 2023, 11:45am UTC](https://forum.keycloak.org/t/how-to-use-keycloak-as-an-identity-provider-with-office365-and-login-to-applications-like-powerapps/18080/6 "2023-04-12T11:45:52Z")

</div>

Hi, I’m trying to do the same thing, could you please help me as well?

I would really appreciate the support.

---

<div class="post-metadata">

**Author:** ![bwatkins79](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/bwatkins79/32/8163_2.png) [@bwatkins79](https://forum.keycloak.org/u/bwatkins79)\
**Post date:** [April 13, 2023, 7:57pm UTC](https://forum.keycloak.org/t/how-to-use-keycloak-as-an-identity-provider-with-office365-and-login-to-applications-like-powerapps/18080/7 "2023-04-13T19:57:50Z")

</div>

Check out my reply here, If you have more questions let me know.  
I’m going to put together a post about my whole setup and process, since I couldn’t find anything really and had to figure it out lol.

> [@Keycloak works for Office365 but fails for SharePoint Online](http://forum.keycloak.org/t/keycloak-works-for-office365-but-fails-for-sharepoint-online/21265/4):
>
> So you definitely do NOT want to add it to External Identities, that is what was breaking mine. I used some of the info from here: [Azure AD Connect: Use a SAML 2.0 Identity Provider for Single Sign On - Azure - Microsoft Entra | Microsoft Learn](https://learn.microsoft.com/en-us/azure/active-directory/hybrid/how-to-connect-fed-saml-idp) Basically you open powershell and use: Connect-MsolService Then set up the federation This is what mine looked like $dom = "[DOMAINNAME]" $BrandName = "[BrandName]" $LogOnUrl = "https://[KeycloakURL]/realms/[REALM]/protocol/saml" $LogOffUrl = "htt…

---

<div class="post-metadata">

**Author:** ![bwatkins79](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/bwatkins79/32/8163_2.png) [@bwatkins79](https://forum.keycloak.org/u/bwatkins79)\
**Post date:** [April 13, 2023, 8:55pm UTC](https://forum.keycloak.org/t/how-to-use-keycloak-as-an-identity-provider-with-office365-and-login-to-applications-like-powerapps/18080/8 "2023-04-13T20:55:27Z")

</div>

Here’s my writeup of the setup im using.

> [@Using Keycloak as IDP for Office365 and SharePoint Online](http://forum.keycloak.org/t/using-keycloak-as-idp-for-office365-and-sharepoint-online/21475):
>
> I recently got Keycloak setup and working as my IDP for Office365 and SharePoint Online. Since it required info from some different sources, I thought I would put my setup here for others looking to do the same. Good source reading: Save the xml config file from Microsoft found here: [https://nexus.microsoftonline-p.com/federationmetadata/saml20/federationmetadata.xml](https://nexus.microsoftonline-p.com/federationmetadata/saml20/federationmetadata.xml) In Keycloak, under your Realm, click Clients Here, import the federationmetadata.xml from Microsoft. You…

---

<div class="post-metadata">

**Author:** ![yiannakosk](https://avatars.discourse-cdn.com/v4/letter/y/9de0a6/32.png) [@yiannakosk](https://forum.keycloak.org/u/yiannakosk)\
**Post date:** [March 6, 2024, 11:50am UTC](https://forum.keycloak.org/t/how-to-use-keycloak-as-an-identity-provider-with-office365-and-login-to-applications-like-powerapps/18080/9 "2024-03-06T11:50:55Z")

</div>

Hello  
Thanks for the Guide, it works for me as well, as soon as I create the user to the Entra ID federated domain as well. Any ideas on how to sync users from KC to Entra ID?

---

<div class="post-metadata">

**Author:** ![pdwonline](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/pdwonline/32/10632_2.png) [@pdwonline](https://forum.keycloak.org/u/pdwonline)\
**Post date:** [June 11, 2024, 9:39am UTC](https://forum.keycloak.org/t/how-to-use-keycloak-as-an-identity-provider-with-office365-and-login-to-applications-like-powerapps/18080/10 "2024-06-11T09:39:48Z")

</div>

> [@yiannakosk](#):
>
> Any ideas on how to sync users from KC to Entra ID?

Using a SCIM provider…
