using System.Threading.Tasks;
using Microsoft.Graph.Models;
using Microsoft.Identity.Client;
using System.Collections.Generic;
static async Task Main(string[] args)
var scopes = new string[] { "https://graph.microsoft.com/.default" };
var tenantId = "c85d8295-dabe-494a-b067-faabc2e2dc2c";
var clientId = "e3bdf28a-fee2-44fe-a414-e8e7d94fab60";
var clientSecret = "R8S8Q~cOKB-5Bg61oc0TaYEfkMxI8Dc~SvweDdzE";
var options = new TokenCredentialOptions
AuthorityHost = AzureAuthorityHosts.AzurePublicCloud
var clientSecretCredential = new ClientSecretCredential(
tenantId, clientId, clientSecret, options);
var graphClient = new GraphServiceClient(clientSecretCredential, scopes);
var userEmail = "t.morita@capitol.hawaii.gov";
var app = ConfidentialClientApplicationBuilder.Create(clientId)
.WithClientSecret(clientSecret)
.WithAuthority($"https://login.microsoftonline.com/{tenantId}")
var authResult = await app.AcquireTokenForClient(scopes).ExecuteAsync();
Subject = "Meeting with John",
Start = new DateTimeTimeZone
DateTime = "2023-04-15T10:00:00",
TimeZone = "Pacific/Honolulu"
End = new DateTimeTimeZone
DateTime = "2023-04-15T11:00:00",
TimeZone = "Pacific/Honolulu"
Attendees = new List<Attendee>
EmailAddress = new EmailAddress
Address = "t.morita@capitol.hawaii.gov",
Type = AttendeeType.Required,
EmailAddress = new EmailAddress
Address = "j.horiuchi@capitol.hawaii.gov",
Type = AttendeeType.Optional,
EmailAddress = new EmailAddress
Address = "r.miyashiro@capitol.hawaii.gov",
Type = AttendeeType.Optional,
var createdEvent = await graphClient.Users[userEmail].Calendar.Events
Console.WriteLine($"Event created with ID: {createdEvent.Id}");