Hello Limilabs,
I need your help to resolve a problem that arises at a customer's installation.
I purchased the mail.dll library (license ID 31f50dcd-ad3e-4c44-ab18-6576edfc31a7) in order to connect to windows service (.Net Fw 4.7.2) with office365 mail box through Azure.
One of the features is to use the oAuth2 protocol, and to do this i followed this guide :
https://www.limilabs.com/blog/oauth2-client-credential-flow-office365-exchange-imap-pop3-smtp
I registered App on Azure, completed and verified each step of the guide and this is the result of the permissions on the mailbox :
PS C:\Users\administrator> Get-MailboxPermission -Identity mailbox@customerdomain.com
Identity User AccessRights IsInherited Deny
-------- ---- ------------ ----------- ----
5706258a-7390-49f... NT AUTHORITY\SELF {FullAccess, ReadPermission} False False
5706258a-7390-49f... b88266ad-ed84-499... {FullAccess} False False
But when try to connect my this code (C#):
oProject pProject /*Class with configuration*/
if (pProject.pop3_UseTLS)
System.Net.ServicePointManager.SecurityProtocol =
System.Net.SecurityProtocolType.Tls12;
var app = ConfidentialClientApplicationBuilder
.Create(pProject.clientId)
.WithTenantId(pProject.tenantId)
.WithClientSecret(pProject.clientSecretvalue)
.Build();
string[] scopes = new string[] {
"https://outlook.office365.com/.default"
};
var result = await app.AcquireTokenForClient(scopes)
.ExecuteAsync();
string accessToken = result.AccessToken;
pProject.pop3_access_token = accessToken
mPop3 = new Limilabs.Client.POP3();
mPop3.ConnectSSL(pProject.pop3_server, pProject.pop3_port);
mPop3.LoginOAUTH2(
pProject.pop3_username, pProject.pop3_access_token);
An exception is raised :
Limilabs.Client.POP3.Pop3ResponseException: Authentication failure: unknown user name or bad password.
at __00000___0.___(Pop3Response 0)
at Limilabs.Client.POP3.Pop3.LoginOAUTH2(String user, String accessToken)
at POP3Main.fetchmessages(oProject pProject)
I also read that the exception is speaking, but I assure you that the clientId, tenantId, clientSecretvalue
and email box (i tryed both "mailbox" and "mailbox@customerdomain.com" as user) are correct.
I tried to set guids intentionally wrong and I get a different error (correctly mail.dll says that app does not exist, tenant does not exist etc etc)
Have you had similar cases, could you give me a suggestion \ hint ?
Thank you very much for your help, I trust you to get out of this situation.