我在Google阅读器测试代码中遗漏了什么?

时间:2011-07-29 09:01:01

标签: java httpclient google-reader

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();
    }
}

我正在测试连接到Google阅读器。

获得SID成功。 所以我制作了一个SID cookie并试图获得一个令牌,但它失败了(403禁止)。

这是一种错误的方式吗?

我使用了Apache HttpClient库。

1 个答案:

答案 0 :(得分:3)

不再支持使用SID Cookie进行Google阅读器API身份验证。支持的身份验证方法是OAuth和ClientLogin;有关详细信息,请参阅http://code.google.com/p/google-reader-api/wiki/Authentication