[android-developers] Android Google Calendar Service getting “400 Bad Request” using ClientLogin
I'm new to Google web services and not sure why my request is not
going through. I'm able to get my Auth token no problem using the
following code:
HttpClient client = new DefaultHttpClient();
String postURL = "https://www.google.com/accounts/ClientLogin";
HttpPost post = new HttpPost(postURL);
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("Email",
"karim.varela@gmail.com"));
params.add(new BasicNameValuePair("Passwd", "XXXXXX"));
params.add(new BasicNameValuePair("service", "cl"));
params.add(new BasicNameValuePair("accountType", "GOOGLE"));
UrlEncodedFormEntity ent = new
UrlEncodedFormEntity(params,HTTP.UTF_8);
post.setEntity(ent);
HttpResponse responsePOST = client.execute(post);
HttpEntity resEntity = responsePOST.getEntity();
if (resEntity != null) {
String response = EntityUtils.toString(resEntity);
authKey = response.substring( response.indexOf("Auth="),
response.length());
authKey = authKey.replace( "Auth=","" );
}
Then, I'm trying to make a simple call to get all the calendars for
karim.varela@gmail.com. As far as I know, it should be a simple GET to
https://www.google.com/calendar/feeds/default/allcalendars/full making
sure to set the header as get.setHeader("Authorization", "GoogleLogin
auth=" + authKey );. This is what I have:
HttpClient client = new DefaultHttpClient();
String getURL = "https://www.google.com/calendar/feeds/default/
allcalendars/full";
HttpGet get = new HttpGet(getURL);
get.setHeader("Authorization", "GoogleLogin auth=" + authKey );
get.setHeader("Content-Type", "application/atom+xml");
HttpResponse responseGet = client.execute(get);
HttpEntity resEntityGet = responseGet.getEntity();
if (resEntityGet != null) {
String response = EntityUtils.toString( resEntityGet );
}
When this code is executed, however, I'm getting a "400 Bad Request"
and then farther down it says "Your client has issued a malformed or
illegal request." Can anybody please help me with this?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home