log.info("getAuthorizationHeader(" + requestUrl + ", " + requestMethod + ") = "
+ helper.getAuthorizationHeaderValue());
return helper.getAuthorizationHeaderValue();
}
};
GDataRequestFactory factory = new GoogleGDataRequest.Factory() {
@Override protected GDataRequest createRequest(RequestType type, URL requestUrl,
ContentType contentType) throws IOException, ServiceException {
return new GoogleGDataRequest(type, requestUrl, contentType, authToken,
headerMap, privateHeaderMap, connectionSource) {
// Superclass method barfs with a NullPointerException because it
// expects a WWW-Authenticate header that isn't there, so override
// it.
@Override protected void handleErrorResponse() throws ServiceException, IOException {
if (httpConn.getResponseCode() == HttpURLConnection.HTTP_UNAUTHORIZED) {
throw new SessionExpiredException("Got response code " + httpConn.getResponseCode()
+ ", token has probably expired");
}
super.handleErrorResponse();
}
};
}
};
factory.setAuthToken(authToken);
ContactsService contacts = new ContactsService(clientId,
factory,
new AuthTokenFactory() {
@Override public AuthToken getAuthToken() {
log.info("getAuthToken()");