throw ErrorHandler.cannotGetAccessToken();
}
System.out.println("got result !");
System.out.println(responseStr);
JSONObject jObj = Converters.toJsonObj(responseStr);
AccessToken token = new AccessToken();
if (jObj.containsKey("access_token")) {
String accessToken = jObj.getString("access_token");
token.setAccessToken(accessToken);
} else {
throw ErrorHandler.cannotGetAccessToken();
}
if (jObj.containsKey("expires_in")) {
int expiresIn = jObj.getInt("expires_in");
token.setExpiresIn(expiresIn);
} else {
throw ErrorHandler.cannotGetAccessToken();
}
if (jObj.containsKey("refresh_token")) {
String refreshToken = jObj.getString("refresh_token");
token.setRefreshToken(refreshToken);
}
if (jObj.containsKey("douban_user_id")) {
String doubanUserId = jObj.getString("douban_user_id");
token.setDoubanUserId(doubanUserId);
}
return token;
}