Is there some particular reason why HttpUnit get requests receive a 
response code of 403 (forbidden)?  Or, is there a problem with how the 
below code works?

There's perhaps some security in place to prevent:

<http://code.google.com/apis/gdata/articles/using_cURL.html>

with HttpUnit (and presumably HtmlUnit)?

I'm looking int HtmlUnit, maybe that will work better, else I'll try 
libcurl for Java <http://curl.haxx.se/libcurl/java/>, but I'd prefer 
HtmlUnit or HttpUnit.


simple HttpUnit class with dummy data:



[thu...@arrakis auth]$ 
[thu...@arrakis auth]$ 
[thu...@arrakis auth]$ java -jar dist/auth.jar 
GET request for (null) https://www.google.com/accounts/ClientLogin?
service=reader&passwd=passwd&email=email&source=Google-cURL-Example
Exception in thread "main" com.meterware.httpunit.HttpException: Error on 
HTTP request: 403 Forbidden [https://www.google.com/accounts/ClientLogin?
service=reader&passwd=passwd&email=email&source=Google-cURL-Example]
        at com.meterware.httpunit.WebClient.validateHeaders
(WebClient.java:623)
        at com.meterware.httpunit.WebClient.updateClient
(WebClient.java:500)
        at com.meterware.httpunit.WebWindow.updateWindow
(WebWindow.java:192)
        at com.meterware.httpunit.WebWindow.getSubframeResponse
(WebWindow.java:183)
        at com.meterware.httpunit.WebWindow.getResponse
(WebWindow.java:158)
        at com.meterware.httpunit.WebClient.getResponse
(WebClient.java:122)
        at auth.Main.main(Main.java:48)
[thu...@arrakis auth]$ 
[thu...@arrakis auth]$ cat src/auth/Main.java 
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package auth;

import com.google.gdata.util.AuthenticationException;
import com.google.gdata.util.ServiceException;
import com.meterware.httpunit.GetMethodWebRequest;
import com.meterware.httpunit.WebConversation;
import com.meterware.httpunit.WebRequest;
import com.meterware.httpunit.WebResponse;
import java.io.IOException;
import java.net.MalformedURLException;
import static java.lang.System.out;
import org.xml.sax.SAXException;

/**
 *
 * @author thufir
 */
public class Main {

    /**
     * curl https://www.google.com/accounts/ClientLogin
    -d Email=just_your_username_here_without_at_gmail_dot_com
    -d Passwd=your_password_here
    -d source=Google-cURL-Example
    -d service=reader
     */
    private static final String SURL = "https://www.google.com/accounts/
ClientLogin";
    private static final String source = "Google-cURL-Example";
    private static final String service = "reader";
    private static String email = "email",  passwd = "passwd";

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws MalformedURLException, 
AuthenticationException, IOException, ServiceException, SAXException {
        WebConversation conversation = new WebConversation();
        WebRequest request = new GetMethodWebRequest(SURL);
        request.setParameter("email", email);
        request.setParameter("passwd", passwd);
        request.setParameter("source", source);
        request.setParameter("service", service);
        out.println(request);

        WebResponse response = conversation.getResponse(request);

        out.print("\n\n\n"+response);
    }
}
[thu...@arrakis auth]$ 



thanks,

Thufir


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Data Protocol" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to