0
votes

I'm building a service where each user has a calendar, I want to sync users 365 calendar events into their calendar, the tricky part seems to be, that this should be done repeatable by background job on the server, to keep them in sync.

I feel like I've read a bible of documentation from Microsoft, but still gotten nowhere. I eventually stumbled upon this article https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-protocols-oauth-client-creds which allows a server to query the graph api, on behalf of users. This is exactly what I want.

Having created a Azure account, and Active Directory service, I found that only users within the tenant can use this, which makes it rather useless, requiring to add users manually from azure panel.

AADSTS50020: User account 'm@****.com' from identity provider 'live.com' does not exist in tenant 'Default Directory' and cannot access the application 'c0193dea-5145-430a-9c90-325f1229a1fc' in that tenant. The account needs to be added as an external user in the tenant first. Sign out and sign in again with a different Azure Active Directory user account.

So I'm back at square one, how can I achieve what I described? I'm not looking for a code implementation, merely a description of how to navigate the monstrosity of Microsoft.

Thank you

Update: Accordingly to Marc link. I tried to flick the multi tenant option, and change the endpoint to use common instead of tenant id. Sadly i'm still getting the same error.

1
Kind of funny, I am actually finishing up a blog article (maybe out in a couple weeks) on this exact scenario. It's going to be about adding an opt-in feature with AAD, in this case a calendar integration, but it also talks about the integration itself. - juunas
@juunas Is there anyway i can pick you brain on this? I feel like i've tried everything, would love some guidance. :-) - MartinElvar
Well, we can chat about it a bit: chat.stackoverflow.com/rooms/167326/… - juunas

1 Answers

1
votes

You cannot sign-in to AAD with a non-AAD account using the v1 Endpoint. If you want to use a consumer Microsoft Account (@outlook.com, @hotmail.com, @live.com) then you need to use the Converged Auth model provided by the v2 Endpoint.

I have a walkthrough for the v2 Endpoint that you might find helpful: Microsoft v2 Endpoint Primer. It is similar to the v1 Endpoint but you'll need to register via https://apps.dev.microsoft.com rather than the Azure Portal. Also, v2 apps use Scopes instead of Resources and are multi-tenant out of the box.


This is a broad a question for Stack Overflow. That said, you're incorrect about Azure AD. It is absolutely not limited to a single-tenant. You do however need to register it as a multi-tenant application:

How to sign in any Azure Active Directory (AD) user using the multi-tenant application pattern