Hello, James, and thanks for responding to my query. During the onboarding phase of our application, we allow the user to synchronize with existing external email accounts; in the case where the user needs to import contacts and email messages from an existing M365 email account. Here using the Microsoft Graph SDK, we need to connect to the user account. Our services via the Confidential Client flow gain access to our Azure AD Tenant but we need to connect to the user M365 account in an external Azure AD Tenant. In reading the docs it is not clear to me, specifically what data, and information I need to give to supply the Graph API given this use-case.
Given this code snippet, do I need to connect to the user's tenant? If so, that would seem problematic; however, I've been reading about Azure AD External Identities and wonder if that is the path forward.
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var user = await graphClient.Me
.Request()
.GetAsync();
Regarding Graph Explorer, I am not even sure how to configure the query to test.
I am testing with this code
private static async Task<Message> ReadUserEmail(string emailAccount)
{
IUserMessagesCollectionPage msgs = await graphClient.Users[emailAccount].Messages.Request()
//.Filter("put your filter here")
.GetAsync();
List<Message> messages = new List<Message>();
messages.AddRange(msgs.CurrentPage);
while (msgs.NextPageRequest != null)
{
await msgs.NextPageRequest.GetAsync();
messages.AddRange(msgs.CurrentPage);
}
return null;
}
and it does not work, reporting that the user does exist in the target Azure AD tenant - that makes sense. So, what is the method and technique required to cross-connect to an external Azure AD Tenant?
Tavi