将PicasawebService与GAE一起使用时出错

时间:2013-10-11 14:32:38

标签: java google-app-engine google-api-java-client picasa

我正在尝试从我的GAE应用程序连接到picasa网络相册。但我无法进行身份验证。

PicasawebService myService = new PicasawebService("myclub");
myService.setUserCredentials("username@gmail.com", "my_password");

我得到的错误是

com.google.gdata.util.AuthenticationException: Error connecting with login URI
    at com.google.gdata.client.GoogleAuthTokenFactory.getAuthToken(GoogleAuthTokenFactory.java:549)
    at com.google.gdata.client.GoogleAuthTokenFactory.setUserCredentials(GoogleAuthTokenFactory.java:397)
    at com.google.gdata.client.GoogleService.setUserCredentials(GoogleService.java:364)
    at com.google.gdata.client.GoogleService.setUserCredentials(GoogleService.java:319)
    at com.google.gdata.client.GoogleService.setUserCredentials(GoogleService.java:303)


Caused by: java.net.SocketTimeoutException: Timeout while fetching: https://www.google.com/accounts/ClientLogin
    at com.google.appengine.api.urlfetch.URLFetchServiceImpl.fetch(URLFetchServiceImpl.java:52)
    at com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection.fetchResponse(URLFetchServiceStreamHandler.java:417)
    at com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection.getInputStream(URLFetchServiceStreamHandler.java:296)
    at com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection.getResponseCode(URLFetchServiceStreamHandler.java:149)
    at com.google.gdata.client.GoogleAuthTokenFactory.makePostRequest(GoogleAuthTokenFactory.java:624)
    at com.google.gdata.client.GoogleAuthTokenFactory.getAuthToken(GoogleAuthTokenFactory.java:547)

有没有人遇到过这个问题?

1 个答案:

答案 0 :(得分:0)

尝试增加超时。我在照片上传时遇到过这种情况,但不是在身份验证上。

我发现从我的开发appengine到picacaweb的500kb照片需要大约17秒,默认超时为10秒。通常,尽管读取响应超时,但上载仍然成功。 60s是最大值,因此如果需要更长的时间,则需要采用不同的策略(上传/捕捉超时/检查照片存在/读取元数据或相应地重新上传)。

PicasawebService.setConnectTimeout(60000);
PicasawebService.setReadTimeout(60000);