0

I am trying to create Online Meeting using microsoft graph api without login into AzureActiveDirectory with asp.net web application.For this my app has below permissions which are required as per documentation https://learn.microsoft.com/en-us/graph/api/application-post-onlinemeetings?view=graph-rest-1.0&tabs=csharp with client credential auth flow https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow without immediate interaction with a user.I am able to retrive access token successfully as per client-creds-grant-flow. I tried Micosoft.Graph and Micosoft.Graph.Beta still getting 404 error.

Create online meeting code

  var graphClient = GetAuthenticatedClientCredential();
            var onlineMeeting = new OnlineMeeting
            {
                StartDateTime = DateTimeOffset.Parse("2020-10-01T10:30:34.2444915+00:00"),
                EndDateTime = DateTimeOffset.Parse("2020-10-01T11:00:34.2464912+00:00"),
                Subject = "Create Online Meeting-Without user login to Office 365"
            };

            return await graphClient.Me.OnlineMeetings
                 .Request()
                 .AddAsync(onlineMeeting);

Access Token code

 public static async Task<string> GetUserAccessTokenAsyncByCc()
        {
            IConfidentialClientApplication cca = ConfidentialClientApplicationBuilder.Create(appId)
               .WithTenantId(appTenantId)
               .WithClientSecret(appSecret)
               .Build(); 
            
             string[] scopes1 = new string[] { "https://graph.microsoft.com/.default" };
            //string[] scopes1 = new string[] { "https://graph.microsoft.com/OnlineMeetings.ReadWrite.All" };
            // string[] scopes1 = new string[] { "https://graph.microsoft.com/beta/OnlineMeetings.Read.All" };
            //string[] scopes1 = new string[] { "https://graph.microsoft.com/beta/.default" };
            var result = await cca.AcquireTokenForClient(scopes1).ExecuteAsync();
           
            return result.AccessToken;
        }

and Auth Provider code

public static GraphServiceClient GetAuthenticatedClientCredential()
        {

            DelegateAuthenticationProvider provider = new DelegateAuthenticationProvider(
                     async (requestMessage) =>
                     {
                         string accessToken = await GetUserAccessTokenAsyncByCc();
                         requestMessage.Headers.Authorization = new AuthenticationHeaderValue("bearer", accessToken);
                     });

            GraphServiceClient graphClient = new GraphServiceClient(provider);

            return graphClient;


        }

app permission image below are the necessary app permission

1 Answer 1

1

You can only use delegated permissions to create an onlineMeeting, so you must log in as a user, and you cannot use the client credential flow. You need to use the auth code flow to obtain the token.

enter image description here

Sign up to request clarification or add additional context in comments.

3 Comments

I have used the auth code flow to obtain the token and successfully create onlinemetting by login into <login.microsoftonline.com/common/>[returns auth code in redirecturl]. But the requirement is without login into <login.microsoftonline.com/common> user should be to create onlinemeeting by sumitting details by login into our webapp.
@anu I don't quite understand what you mean.
Ok let me explain.Auth code provider needs redirectURL to return authcode but before that user have to login into <login.microsoftonline.com/common>.Here user has to login twice.into our my web app and microsoft login.Hope u understand till now.My requirement is when user login into our webapp he again need not to login into<login.microsoftonline.com/common> to create online meeting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.