We are using Rebex 6.3 for POP3 and SMTP and need to change the Authentication to
OAuth2. According to Samples Pop3OAuthAppOnlyConsole and ImapOAuthAppOnlyConsole i tried to connect.
With POP3 everything works fine till
var authResult = await cca.AcquireTokenForClient(scopes).ExecuteAsync();
string accessToken = authResult.AccessToken;
// connect using Rebex POP3 and retrieve list of messages
using (var client = new Pop3())
{
// communication logging (enable if needed)
//client.LogWriter = new FileLogWriter("pop3-oauth.log", LogLevel.Debug);
// connect to the server
Console.WriteLine("Connecting to POP3...");
await client.ConnectAsync("outlook.office365.com", SslMode.Implicit);
// authenticate using the OAuth 2.0 access token
Console.WriteLine("Authenticating to POP3...");
await client.LoginAsync("xxx@concept.onmicrosoft.com", accessToken, Pop3Authentication.OAuth20);
// list recent messages
Console.WriteLine("Listing messages...");
int count = client.GetMessageCount();
}
on client.GetMessageCount() i got Exception:
"Command is not valid in this state."
" bei Rebex.Net.Pop3.fpwda(Boolean p0, Boolean p1, String& p2)\r\n bei Rebex.Net.Pop3.robfu(Int32& p0, Int64& p1)\r\n bei Rebex.Net.Pop3.itnfd()\r\n bei Sc.Lib.App.Oauth2TestForm.d__38.MoveNext() in C:\Projects\CO70.NET\_repo\Office\Tools\Oauth2Test\Oauth2TestForm.cs:Zeile 81."
With IMAP i got Exception on trying to Login
await client.LoginAsync("xxxxxx@concept.onmicrosoft.com", authResult.AccessToken, ImapAuthentication.OAuth20);
"AUTHENTICATE failed (NO)."
" bei Rebex.Net.Imap.ckfej(String p0, ImapResponse p1, Boolean p2)\r\n bei Rebex.Net.Imap.raucp(String p0)\r\n bei Rebex.Net.Imap.gjkvd(String p0, String p1, ImapAuthentication p2, GssApiProvider p3)\r\n bei Rebex.Net.Imap.gwcxn(String p0, String p1, ImapAuthentication p2)\r\n bei Rebex.Net.Imap.xpigz(Object p0, Enum p1, Object[] p2)\r\n bei dxklq.xzusb.vjspj(Object p0)\r\n--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---\r\n bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n bei System.Runtime.CompilerServices.TaskAwaiter.GetResult()\r\n bei Sc.Lib.App.Oauth2TestForm.d__38.MoveNext() in C:\Projects\CO70.NET\_repo\Office\Tools\Oauth2Test\Oauth2TestForm.cs:Zeile 132."
Is there still no way to Use Rebex.SMTP for daemon app wird Seret authentication ?