只是想知道怎么做。android给出的token与常规google reader认证中使用的token相同。以下是 Christian Dadswell 使用 Jsoup 编写的一些代码,并经过修改以与 Android authtoken 一起使用:
public static String getGoogleToken(String authKey) throws UnsupportedEncodingException, IOException
{
Document doc = Jsoup.connect(_TOKEN_URL).header("Authorization", _AUTHPARAMS + authKey).userAgent(_USER_AGENT).timeout(4000).get();
// RETRIEVES THE RESPONSE TOKEN
String _TOKEN = doc.body().text();
return _TOKEN;
}
和
public static String getUserInfo(String authKey) throws UnsupportedEncodingException, IOException
{
Document doc = Jsoup.connect(_USER_INFO_URL).header("Authorization", _AUTHPARAMS + authKey).userAgent(_USER_AGENT).timeout(4000).get();
// RETRIEVES THE RESPONSE USERINFO
String _USERINFO = doc.body().text();
return _USERINFO;
}
和常数:
private static String _USER_AGENT = "YourAppNameHere";
private static final String _AUTHPARAMS = "GoogleLogin auth=";
private static final String _GOOGLE_LOGIN_URL = "https://www.google.com/accounts/ClientLogin";
private static final String _READER_BASE_URL = "http://www.google.com/reader/";
private static final String _API_URL = _READER_BASE_URL + "api/0/";
private static final String _TOKEN_URL = _API_URL + "token";
private static final String _USER_INFO_URL = _API_URL + "user-info";
private static final String _USER_LABEL = "user/-/label/";
private static final String _TAG_LIST_URL = _API_URL + "tag/list";
private static final String _EDIT_TAG_URL = _API_URL + "tag/edit";
private static final String _RENAME_TAG_URL = _API_URL + "rename-tag";
private static final String _DISABLE_TAG_URL = _API_URL + "disable-tag";
private static final String _SUBSCRIPTION_URL = _API_URL + "subscription/edit";
private static final String _SUBSCRIPTION_LIST_URL = _API_URL + "subscription/list";