|
5 | 5 | using MailKit.Security; |
6 | 6 | using Microsoft.Identity.Client; |
7 | 7 |
|
8 | | -var clientId = "7dc85a6b-127b-45d2-ba1d-837f95aba0c7"; |
9 | | -var tenantId = "2aaa4b86-cc65-43c7-b348-89f4cb2b5c69"; |
| 8 | +var clientId = "<clientId>"; |
| 9 | +var tenantId = "<tenantId>"; |
10 | 10 |
|
11 | 11 | //var options = new PublicClientApplicationOptions |
12 | 12 | //{ |
|
39 | 39 | //} |
40 | 40 |
|
41 | 41 | var scopes = new string[] { |
42 | | - "email", |
| 42 | + //"email", |
43 | 43 | //"offline_access", |
44 | | - "https://outlook.office.com/IMAP.AccessAsUser.All", // Only needed for IMAP |
45 | | - //"https://outlook.office.com/POP.AccessAsUser.All", // Only needed for POP |
46 | | - //"https://outlook.office.com/SMTP.Send", // Only needed for SMTP |
| 44 | + "https://outlook.office365.com/.default", |
| 45 | + //"https://outlook.office.com/IMAP.AccessAsUser.All", // Only needed for IMAP |
| 46 | + //"https://outlook.office.com/POP.AccessAsUser.All", // Only needed for POP |
| 47 | + //"https://outlook.office.com/SMTP.Send", // Only needed for SMTP |
47 | 48 | //"https://graph.microsoft.com/.default", |
48 | 49 | }; |
49 | 50 |
|
50 | 51 | var confidentialClientApplication = ConfidentialClientApplicationBuilder |
51 | 52 | .Create(clientId) |
52 | | - .WithClientSecret("a8C8Q~~JWQc4U2jMmUiwZY9BduG5pUaa2E9h9dtQ") |
53 | | - .WithAuthority(new Uri("https://login.microsoftonline.com/" + tenantId + "/")) |
| 53 | + .WithClientSecret("<client-secret>") |
| 54 | + .WithAuthority(new Uri("https://login.microsoftonline.com/" + tenantId + "/v2.0")) |
54 | 55 | .Build(); |
55 | 56 |
|
56 | 57 | var authenticationResult = await confidentialClientApplication.AcquireTokenForClient(scopes).ExecuteAsync(); |
57 | 58 |
|
58 | 59 | var authToken = authenticationResult; |
59 | | -var oauth2 = new SaslMechanismOAuth2("[email protected]", authToken.AccessToken); |
| 60 | +var oauth2 = new SaslMechanismOAuth2("<email address to access>", authToken.AccessToken); |
60 | 61 |
|
61 | 62 | using (var client = new ImapClient(new ProtocolLogger("imapLog.txt"))) |
62 | 63 | { |
|
0 commit comments