如何将抄写授权与gdata服务相结合

时间:2012-06-08 08:54:55

标签: gdata scribe

有谁知道如何将抄写员与抄写员结合使用Gdata服务:

因此在使用scribe进行身份验证后,我有访问令牌并需要将其推送到gdata ContactsService的实例(对于任何其他服务,它的工作原理相同,我猜)。

我尝试过简单的

GoogleCredential credential = new GoogleCredential();
credential.setAccessToken(accessTokenString);

其中accessTokenString是在运行

后从scribe获得的String
Token accessToken = service.getAccessToken(requestToken, verifier);

但是在执行请求时这不起作用:

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)
at com.google.gdata.client.Service.getFeed(Service.java:998)
at com.google.gdata.client.GoogleService.getFeed(GoogleService.java:645)
at com.google.gdata.client.Service.getFeed(Service.java:1017)

将scribe与gdata结合起来会很好,因为我已经准备好了,gdata提供了更好的api来处理谷歌的数据

由于

1 个答案:

答案 0 :(得分:0)

我不知道你的例子中有accessTokenString。我假设它是在Scribes accessToken对象上调用toString方法的结果。

如果是这样,并且gdata只期望访问令牌,那么你应该这样做:

Token accessToken = service.getAccessToken(requestToken, verifier);
GoogleCredential credential = new GoogleCredential();
credential.setAccessToken(accessToken.getToken());