Android XMPP simple chat: Login error SASL authentication failed using mechanism PLAIN

2.1k Views Asked by At

as the title says I'm new to android. I'm trying to build very simple chat with the following code.

//1. connection
ConnectionConfiguration connConfig = new ConnectionConfiguration("talk.google.com", 5222, "gmail.com");
try{ connection.connect();}
catch (XMPPException ex)
{   
 connection = null;
 return;
}

//2. login
try{  connection.login(myGmailLogin,myGmailPwd); }
catch (XMPPException e)
{
  report+="Login error " + e.toString() ;
  return;
}

What i get Is: Login error SASL authentication failed using mechanism PLAIN. By googling i've found dozens of pages from people having the same problem but no solution worked. can anyone please help me? thanx a lot!

1

There are 1 best solutions below

1
On
  1. Use ConnectionConfiguration connConfig = new ConnectionConfiguration("gmail.com");, all other params will be set automatically
  2. Google does not allow PLAIN authentication on the insecure connection, make sure TLS connection is required: connConfig.setSecurityMode(SecurityMode.required);