Skip to content

Commit 986db99

Browse files
jorgemvcalkampfergit
authored andcommitted
Minor fixes
Some changes to scope and url authority to make it run without errors
1 parent 62b54a0 commit 986db99

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/ConsoleAppTest/Program.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
using MailKit.Security;
66
using Microsoft.Identity.Client;
77

8-
var clientId = "7dc85a6b-127b-45d2-ba1d-837f95aba0c7";
9-
var tenantId = "2aaa4b86-cc65-43c7-b348-89f4cb2b5c69";
8+
var clientId = "<clientId>";
9+
var tenantId = "<tenantId>";
1010

1111
//var options = new PublicClientApplicationOptions
1212
//{
@@ -39,24 +39,25 @@
3939
//}
4040

4141
var scopes = new string[] {
42-
"email",
42+
//"email",
4343
//"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
4748
//"https://graph.microsoft.com/.default",
4849
};
4950

5051
var confidentialClientApplication = ConfidentialClientApplicationBuilder
5152
.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"))
5455
.Build();
5556

5657
var authenticationResult = await confidentialClientApplication.AcquireTokenForClient(scopes).ExecuteAsync();
5758

5859
var authToken = authenticationResult;
59-
var oauth2 = new SaslMechanismOAuth2("[email protected]", authToken.AccessToken);
60+
var oauth2 = new SaslMechanismOAuth2("<email address to access>", authToken.AccessToken);
6061

6162
using (var client = new ImapClient(new ProtocolLogger("imapLog.txt")))
6263
{

0 commit comments

Comments
 (0)