Hello,
I have just started using ContactsService in a new way, with OAuth2, using
GoogleCredential
mechanism.
Unfortunately it seems there is a bug in the gdata lib or the protocol!
Whenever my token expires the library throws the NPE exception because "
WWW-Authenticate" si not available in the response. So SessionExpiredException
exception is never thrown and the credential's refreshToken listener is
never called.
Any suggestions?
>>>Token invalid - Invalid token: Stateless token expired<<<
Exception in thread "main" java.lang.NullPointerException: No
authentication header information
at com.google.gdata.util.AuthenticationException.initFromAuthHeader(
AuthenticationException.java:96)
at com.google.gdata.util.AuthenticationException.<init>(
AuthenticationException.java:67)
at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(
HttpGDataRequest.java:608)
at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(
GoogleGDataRequest.java:564)
at com.google.gdata.client.http.HttpGDataRequest.checkResponse(
HttpGDataRequest.java:560)
at com.google.gdata.client.http.HttpGDataRequest.execute(
HttpGDataRequest.java:538)
at com.google.gdata.client.http.GoogleGDataRequest.execute(
GoogleGDataRequest.java:536)
at com.google.gdata.client.Service.getFeed(Service.java:1135)
GoogleCredential credential = new GoogleCredential.Builder()
.setTransport(new NetHttpTransport())
.setJsonFactory(new JacksonFactory())
.setClientSecrets(CLIENT_ID,
CLIENT_SECRET)
.addRefreshListener(new CredentialRefreshListener() {
@Override
public void onTokenResponse(Credential credential,
TokenResponse tokenResponse) {
svc.setAccessToken(tokenResponse.getAccessToken());
if (tokenResponse.getRefreshToken() != null)
svc.setRefreshToken(tokenResponse.getRefreshToken());
}
@Override
public void onTokenErrorResponse(Credential credential,
TokenErrorResponse tokenErrorResponse) {
svc.setAccessToken(null);
svc.setRefreshToken(null);
}
}).build();
credential.setAccessToken(svc.getAccessToken());
credential.setRefreshToken(svc.getRefreshToken());
myService = new ContactsService("App-1");
myService.setOAuth2Credentials(credential);
--
You received this message because you are subscribed to the Google
Groups "Google Contacts, Shared Contacts and User Profiles APIs" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://code.google.com/apis/contacts/community/forum.html