I'm working on a calendar web application where I want to create a Teams meeting and add the meeting (the join-URL) to an appointment.
As not all of my users log in via Microsoft OAuth 2.0 login, I have to create the teams meeting on the server side (as application). I created an Azure app registration for my application and assigned it the API-permission "OnlineMeetings.ReadWrite.All" (Application). My application is using the client credentials authentication flow.
Now the actual problem:
I tried to create the onlineMeeting according to this Microsoft doc: Create onlineMeeting
The docs say, that I have to create an "application access policy" to create onlineMeetings as an application (Allow applications to access online meetings on behalf of a user)
So my question is: Is there really no straight forward way to create online meetings? In my opinion this is the most basic thing somebody wants to do when using Microsoft Graph in a Teams context. I can't believe that an admin has to take that much effort and connect oneself with a "Skype for business online"- PowerShell (Configure application access policy) and give the permission for every single user manually. I thought the Azure API permissions should exactly cover cases like that.
For testing purposes I tried the following, but only got the Microsoft.Graph.ServiceException "Code: General Message: User not found.". I think this is because my AuthenticationProvider is a ClientCredentialProvider and I am accessing an API for a user.
var client = new GraphServiceClient(azureService.ClientCredentialProvider);
var onlineMeeting = new OnlineMeeting()
{
StartDateTime = start,
EndDateTime = end,
Subject = subject
};
var test = await client.Me.OnlineMeetings
.Request()
.AddAsync(onlineMeeting);
Therefore, I also tried it this way (Microsoft.Graph.ServiceException: 'Code: BadRequest Message: An error has occurred.):
var meeting = await client.Communications.OnlineMeetings
.Request()
.AddAsync(onlineMeeting);
and that way (Microsoft.Graph.ServiceException: 'Code: BadRequest Message: This API is Not supported. createOrGet action is only supported for /me/onlineMeetings/createorGet):
var meeting = await client.Communications.OnlineMeetings
.CreateOrGet(new Guid().ToString(), null, end, participants, start, subject)
.PostAsync();
So is there any other API or possibility that would fulfill my requirements? Meanwhile, I am a little frustrated and would be really grateful for any hint.