Hi Alex thanks for the snippet. I have modfied the classes which you have provided. Below is my classes and Code where i am assiging XmppClient.SalsHandler.
But i am getting below error at XmppXElement x = await saslProc.AuthenticateClientAsync(xmppClient, cancellationToken);.
Please let me know if i am doing it wrong.
XmppXElement x =await myDefaultSaslHandler.AuthenticateAsync(mechanisms, xmppClient, cancellationToken);
ERROR -
at Matrix.Network.Handlers.XmppStanzaHandler.<SendAsync>d__33.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Matrix.Network.Handlers.XmppStanzaHandler.<SendAsync>d__52`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Matrix.Network.Handlers.XmppStanzaHandler.<SendAsync>d__44`2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Matrix.Network.Handlers.XmppStanzaHandler.<SendAsync>d__42`2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Matrix.XmppConnection.<SendAsync>d__50`2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Matrix.XmppConnection.<SendAsync>d__49`2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at com.Helpers.MyPlainProcessor.<AuthenticateClientAsync>d__0.MoveNext()
This post was edited 3 times, last on 2017-11-16, 09:34 by Alex. Edit reason: fixed code formatting
In you last code snippet: you don't need line 10-14, remove it and just open the connection. MatriX should use you custom Sasl mechanism then automatically during login. You cannot call AuthenticateClientAsync yourself.
You have not implemented OAuth in MyPlainProcessor yet. You just copied GetMessage from my SASL PLAIN example, which is building a SASL PLAIN authentication message, not an OAUTH authentication message.
Hey Alex thanks for the reply as per your last comments i have modified my code it working fine with SASL PLAIN. It would be great if you provide sample for oAuth.
you have to look in the ejabberd docs how the OAUTH authentication message should look.
Other servers we worked with in the past expexted a message like this:
The AuthorizationCode code has be requested over HTTP APIs which is out of the scope of MatriX. Of course you can build that into your custom Auth classes.