java - 将 PicasawebService 与 GAE 结合使用时出错

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

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

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)

有人遇到过这个问题吗?

最佳答案

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

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

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

关于java - 将 PicasawebService 与 GAE 结合使用时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19320768/

相关文章:

java - 如何在 Vaadin 中制作加载开始栏

java - Google App Engine 数据库模型

java - 尝试获取《纽约时报》页面时,使用 GAE 的 URLFetchService 返回 null

java - 如何使用 Java 查找应用程序引擎数据存储中具有最大重复项的值?

coldfusion - Google Java API 与 ColdFusion CFHTTP 冲突?

java - Google Drive API Java,身份验证仅在第一次时有效

java - 适用于 Java 的优秀且有效的 CSV/TSV 阅读器

c# - 数学公式设计模式

java - Spring MVC @ContextConfiguration

android - 阅读超时上传到谷歌驱动器