I ran into this one long ago -- scripted clients don't take advantage of the typical challenge/response in basic auth.

All you need to do it authenticate preemptively by doing:

abderaClient.userPreemptiveAuthentication(true);


Charles


David Calavera wrote:
I suppose you have a problem with the authentication header XD. You can try
to solve it using our GoogleLogin authentication extension, there is an
example here:
http://svn.apache.org/repos/asf/incubator/abdera/java/trunk/examples/src/main/java/org/apache/abdera/examples/appclient/Services.java

On Tue, Dec 2, 2008 at 10:17 PM, Jalal U Mahmud <[EMAIL PROTECTED]> wrote:


Hello

 I am trying to post atom entry using apache abdera (still learning it).
 I am having some problems while posting (but I can read from it).

. Here is the code fragment I am using:

abdera = new Abdera();
AbderaClient abderaClient = new AbderaClient(abdera);

Factory factory = abdera.getFactory();
Entry entry = factory.newEntry();

entry.setId(FOMHelper.generateUuid());
entry.setUpdated(new java.util.Date());

entry.addAuthor("Jalal");
entry.setTitle("Posting to Blogger");
entry.setContentAsXhtml("<p>This is an example post to the new blogger
beta</p>");

// using real username and password.
String auth = BasicScheme.authenticate(new UsernamePasswordCredentials(
"username", "password"));

RequestOptions rOptions = new RequestOptions();
rOptions.setAuthorization(auth);

ClientResponse resp = abderaClient.post(
"http://buetcse96.blogspot.com/feeds/posts/default";, entry, rOptions);


     if (resp.getType() == ResponseType.SUCCESS) {
               // success
             System.out.println("it is a success");
                   System.out.println("hello world" + resp.getStatusText()
+ "and" + resp.getLastModified());
                   //ResponseType.

             } else {
               // there was an error
                   System.out.println("it is an error" + resp.getType() +
"and: " + resp.getStatusText() +
                                          " and:" + resp.getUri() + "
and:" + resp.getServerDate());
             }



Output:

Dec 2, 2008 1:06:15 PM org.apache.commons.httpclient.HttpMethodBase
writeRequest
INFO: 100 (continue) read timeout. Resume sending the request
Dec 2, 2008 1:06:15 PM org.apache.commons.httpclient.HttpMethodDirector
isAuthenticationNeeded
INFO: Authentication requested but doAuthentication is disabled
it is an error CLIENT_ERROR and: Unknown authorization header



However, reading from that feed works...

Any idea why I am getting this error ?


-jalal.





Reply via email to