loginAnonymously() failing with No anonymous SASL authentication mechanism available

Stream features return this

stream:featuresPLAINDIGEST-MD5X-OAUTH2SCRAM-SHA-1</me chanism></stream:features>

I need to register a user and looks like I need to login anonymously first and then use the AccountManager to create the new user. Otherwise i get the forbidden auth error.

But when i try to call the loginAnonymously() method on the connection it fails with

org.jivesoftware.smack.SmackException: No anonymous SASL authentication mechanism available

This is my config setup

config.setSecurityMode(ConnectionConfiguration.SecurityMode.required);

config.setServiceName(getService());

config.setHost(getHost());

config.setPort(getPort());
config.setDebuggerEnabled(true);

config.setSendPresence(true);

Not sure how to proceed from here. Please help. Thanks