From dd585e4c409d8134fc7b7ec08186c2359e470016 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Wed, 16 Aug 2023 11:25:19 -0400 Subject: [PATCH] Update ExchangeOAuth2.md --- ExchangeOAuth2.md | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/ExchangeOAuth2.md b/ExchangeOAuth2.md index e43c743e53..29ef67ff1e 100644 --- a/ExchangeOAuth2.md +++ b/ExchangeOAuth2.md @@ -120,13 +120,8 @@ nuget package for obtaining the access token which will be needed by MailKit to server. ```csharp -var options = new ConfidentialClientApplicationOptions { - ClientId = "Application (client) ID", - TenantId = "Directory (tenant) ID" -}; - -var confidentialClientApplication = ConfidentialClientApplicationBuilder - .CreateWithApplicationOptions (options) +var confidentialClientApplication = ConfidentialClientApplicationBuilder.Create (clientId) + .WithCertificate (certificate) // or .WithCliehtSecret (clientSecret) .Build (); var scopes = new string[] { @@ -137,7 +132,8 @@ var scopes = new string[] { // "https://outlook.office365.com/.default" }; -var authToken = await confidentialClientApplication.AcquireTokenForClient (scopes).ExecuteAsync (); +var authToken = await confidentialClientApplication.AcquireTokenForClient (scopes) + .WithAuthority (AzureCloudInstance.AzurePublic, "{tenantID}").ExecuteAsync (); var oauth2 = new SaslMechanismOAuth2 (authToken.Account.Username, authToken.AccessToken); using (var client = new ImapClient ()) {