Skip to content

Commit

Permalink
Update ExchangeOAuth2.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jstedfast authored Aug 16, 2023
1 parent b5c6fad commit dd585e4
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions ExchangeOAuth2.md
Original file line number Diff line number Diff line change
Expand Up @@ -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[] {
Expand All @@ -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 ()) {
Expand Down

0 comments on commit dd585e4

Please sign in to comment.