X-OAUTH2 on Smack

Hi,
what’s the correct way to login to XMPP server usign X-OAUTH2?
Can someone please provide a code snippet?

Thanks

There is some X-AOUTH2 code in Smack, but I don’t know if it still works. In theory, the provided password will simply be used as OAUTH2 token. Looking at the code indicates that some attributes may missing. You should be able to use the existing code as starting point for a working implementation.

May I ask what is using X-OAUTH2 with XMPP these days?

Ok, I figured it out.
The class SASLXOauth2Mechanism is still worrking, so I can force smack to use OAUTH2 with the following code:

    SASLAuthentication.unregisterSASLMechanism(SASLPlainMechanism::class.java.name)
    SASLAuthentication.unregisterSASLMechanism(SASLDigestMD5Mechanism::class.java.name)
    SASLAuthentication.unregisterSASLMechanism(SASLExternalMechanism::class.java.name)
    SASLAuthentication.unregisterSASLMechanism(SCRAMSHA1Mechanism::class.java.name)
    SASLAuthentication.unregisterSASLMechanism(ScramSha1PlusMechanism::class.java.name)
    SASLAuthentication.unregisterSASLMechanism(SASLAnonymous::class.java.name)
    SASLAuthentication.unregisterSASLMechanism(SASLExternalMechanism::class.java.name)

The the login does not change becase the sent nonza is the correcly formatted:
xmppConnection.login(username, password, resource)

By the way,

May I ask what is using X-OAUTH2 with XMPP these days?

Rare, but some servers still use it.

Thanks

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.