Search code examples
javahttpclientgoogle-reader

What did I miss in this Google Reader test code?


public void getToken() {

    BasicClientCookie cookie = new BasicClientCookie("SID", sid);
    cookie.setPath("/");
    cookie.setDomain(".google.com");

    CookieStore store = new BasicCookieStore();        
    store.addCookie(cookie);

    String url = "http://www.google.com/reader/api/0/token";

    HttpClient httpclient = new DefaultHttpClient();
    HttpGet req = new HttpGet(url);

    ((DefaultHttpClient)httpclient).setCookieStore(store);

    try {
        token = httpclient.execute(req, Misc.StringRespHandler);
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

I'm testing to connect to Google Reader.

Getting SID was successful. So I made a SID cookie and tried to get a token, but it failed (403 forbidden).

Is it a wrong way?

I used Apache HttpClient library.


Solution

  • Using a SID cookie for Google Reader API authentication is no longer supported. Supported authentication methods are OAuth and ClientLogin; see http://code.google.com/p/google-reader-api/wiki/Authentication for more details.