I try make authentication using ClientLogin
URL url = new URL("https://www.google.com/accounts/ClientLogin");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setRequestMethod("POST");
connection.setRequestProperty("Email", "testonly%2Ein%2E2011%40gmail%2Ecom");
connection.setRequestProperty("Passwd", "mypass");
connection.setRequestProperty("accountType", "HOSTED");
connection.setRequestProperty("service", "apps");
connection.connect();
But I get Error=BadAuthentication
. How I should correct my code?
You should set the proper
application/x-www-form-urlencoded Content-type
and use theOutputStream
to write the POST body.See this example to handle the result to get the
auth
token.