I want to build an add-in for the MS Outlook 2019 desktop app (-> VSTO add-in). It is intended to gather some information from O365 Modern Groups that the current Outlook user (me) is a member of. As far as I understand the only way to achieve this is to use Microsoft Graph API because there is no support to access O365 related things via Outlook object model/Office Interop. Given that (and please correct me if I am wrong) I might use the Microsoft.Graph Nuget packages. With them I would like to call the following endpoint:
POST /users/{id | userPrincipalName}/getMemberGroups
possible in C# with this code snippet:
GraphServiceClient graphClient = new GraphServiceClient(authProvider);
var securityEnabledOnly = true;
await graphClient.Me
.GetMemberGroups(securityEnabledOnly)
.Request()
.PostAsync();
My question is: Is there a way of using the existing Outlook credentials for the authProvider so that I don't need the user to enter credentials? I read that web add-ins have the possibility to use different authentication flows including a SSO flow. But that does not fit for VSTO.
I thought of a IntegratedWindowsAuthenticationProvider. But therefore I need to provide a clientId which I do not have. Does that ultimately mean that I need to register my add-in in some way? Can't I just write an add-in for my personal purposes without admin support?
IPublicClientApplication publicClientApplication = PublicClientApplicationBuilder
.Create(clientId)
.WithTenantId(tenantID)
.Build();
IntegratedWindowsAuthenticationProvider authProvider = new IntegratedWindowsAuthenticationProvider(publicClientApplication, scopes);