The most convenient way is using Curl:
curl https://www.google.com/accounts/ClientLogin -d Email=$1 -d Passwd=$2 -d accountType=GOOGLE -d source=companyName-applicationName-versionID -d service=ac2dm
Replace $1 with your sender google email account address
Replace $2 with your sender google email account password
Replace companyName-applicationName-versionID with something like "Gulp-CalGulp-1.05"
It may take more than 1 minute to get the response. Be patient.
The correct respond is like:
SID=DQAAAJ8AAAA5T7O-MDmbawKYIu9hynZdLyOHXxYqk3OpPiEc3EYbqGm--ajm7C3PljC2wjMcZo_xsJU-dSAC47o_8LLxn1SkAk35H-f518xG230kpn-Xf0ih-NC_vTqsQtoxbwsNKFoclLxQerQDc-uhZykoOVhRpHubzu4z2yHlyDVg2gBf2Brzmim42UeuRIuKfrEbL8ABedNvf4lBtFc4WGOcymQkSID and LSID is useless. What we want is the "Auth";
LSID=DQAAAKMAAADwRO5fShHp_tQD2ZdtcWYqIYGJJBTsC80gOwNIE0-XbGKLJuUfkeDIKDC8iMVUP9_MF9TT9bNQLaimGEm6vtmpjvlaqDOE4p1_LWQM7oLkr9a7jefDeW7CcBymc-wMq-PlmXryYNPwQI58vs49axcZ9ttZ-PJ_bVUh4KYbbz92slXbUXrB2Ib0VunGiTN3OnhdpsYMMarur2EkTxpNVfkQ2PbXn5ZVgU9YoKa4VvfEpW
Auth=DQAAAKIAAABfLQ4rHOJIPIjJtQnLppK17Fh5wmlEo7CEBKPhDYHT6iysIhxNCPTN9AL-UVKEiorr12XrSQs2KhvFgaT81dqDTpk8Ff7lZCixo3VqaL_at4cFn2O013Ff9034pvBniMr0IatPcQJMlw0Ve9-mN_y7aIVgK935B6a70qI9iWBIhKoP7zza0dgIlpjbtLXTYLz46ioR8NR6g87-fDxVIt05KUgtdPS9mjn8eK1kCu9L6Q
Another option using Java program to get ClientLogin Token:
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(
"https://www.google.com/accounts/ClientLogin");
try {
List nameValuePairs = new ArrayList(1);
nameValuePairs.add(new BasicNameValuePair("Email", "your_sender_email@gmail.com"));
nameValuePairs.add(new BasicNameValuePair("Passwd", "your_sender_email_password"));
nameValuePairs.add(new BasicNameValuePair("accountType", "GOOGLE"));
nameValuePairs.add(new BasicNameValuePair("source",
"Company-App-Version"));
nameValuePairs.add(new BasicNameValuePair("service", "ac2dm"));
post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = client.execute(post);
BufferedReader rd = new BufferedReader(new InputStreamReader(
response.getEntity().getContent()));
String line = "";
String auth = "";
while ((line = rd.readLine()) != null) {
Log.e("HttpResponse", line);
if (line.startsWith("Auth=")) {
auth = line.substring(5);
Toast.makeText(this, auth, Toast.LENGTH_LONG).show();
}
}
} catch (IOException e) {
e.printStackTrace();
}
thank you, I help me out of my trouble
ReplyDeleteThanx man solved my problem..
ReplyDelete