On Oct 5, 2006, at 6:31 PM, James M Snell wrote:

The other way is to use the GoogleLoginAuthCredentials:

 Client client = new CommonsClient();

 GoogleLoginAuthCredentials credentials =
   new GoogleLoginAuthCredentials(
     "email", "password", "blogger");

 client.addCredentials(
   "http://beta.blogger.com";,
   null, null,
   credentials);

This will perform the GoogleLogin once and reuse the auth token for each
request.

OK, I've tried for hours but still cannot use this method to authenticate. Here is the relevant snippet from my code:

        Client client = new CommonsClient();
        GoogleLoginAuthScheme.register();
GoogleLoginAuthCredentials credentials = new GoogleLoginAuthCredentials(GOOGLE_USERID,
                GOOGLE_PASSWORD, "cl");
        client.addCredentials(baseUrl, null, null, credentials);
        // client.usePreemptiveAuthentication(true);
ClientResponse response = doPost(client, privateCalendarUrl, event);

The error I get is:

ERROR - HttpMethodDirector         - Missing service in challenge
org.apache.commons.httpclient.auth.MalformedChallengeException: Missing service in challenge at org.apache.abdera.ext.gdata.GoogleLoginAuthScheme.processChallenge (GoogleLoginAuthScheme.java:70) at org.apache.commons.httpclient.auth.AuthChallengeProcessor.processChallen ge(AuthChallengeProcessor.java:161) at org.apache.commons.httpclient.HttpMethodDirector.processWWWAuthChallenge (HttpMethodDirector.java:686) at org.apache.commons.httpclient.HttpMethodDirector.processAuthenticationRe sponse(HttpMethodDirector.java:660) at org.apache.commons.httpclient.HttpMethodDirector.executeMethod (HttpMethodDirector.java:192) at org.apache.commons.httpclient.HttpClient.executeMethod (HttpClient.java:396) at org.apache.commons.httpclient.HttpClient.executeMethod (HttpClient.java:324) at org.apache.abdera.protocol.client.CommonsClient.execute (CommonsClient.java:130)
        at org.apache.abdera.protocol.client.Client.post(Client.java:139)

I've also tried using preemptive authentication (which the Google Data API seems to want) but this fails also, because it looks like HttpClient (3.0) cannot do preemptive authentication with anything else but a BasicAuthScheme.

Some help would really be appreciated, I'm completely stuck.

        Ugo

Reply via email to