简单的 Android Picasa 相册列表请求禁止 403

发布于 2024-12-15 00:08:52 字数 1763 浏览 1 评论 0原文

我从 Android 访问 Picasa 时遇到了麻烦。经过几个小时的研究,我终于确定 Google API Java 客户端图书馆是我应该使用的。几个小时后,我意识到我必须使用 Mercurial 和 Maven 下载并构建一个 示例客户端,以便我可以获得 下载说明。当然,示例客户端与 Picasa 开发人员指南

因此,在经历了很多麻烦之后,我创建了一个简单的 URL 并尝试使用示例客户端中的代码为用户列出相册:

PicasaUrl url = PicasaUrl.relativeToRoot("feed/api/user/someuser");
UserFeed userFeed = client.executeGetUserFeed(url);

现在,创建的实际 URL 类似于:

https://picasaweb.google.com/data/feed/api/user/someuser?prettyprint=true

如果我将其放入浏览器中,它就可以正常工作。然而,在我的 Android 客户端中,它给了我一个 HTTP 403 禁止错误。不,我什至无法运行示例客户端,因为它没有给我 APK 文件。 (而且源代码没有记录,写得像意大利面条一样,并且使用了不推荐使用的方法。)

打开协议级日志记录后,事实证明这是正在发送的 HTTP 请求:

GET https://picasaweb.google.com/data/feed/api/user/someuser?fields=author/name,entry(@gd:etag,category(@scheme,@term),gphoto:access,gphoto:numphotos,link(@href,@rel),summary,title,updated),link(@href,@rel),openSearch:totalResults&kinds=album&max-results=3&prettyprint=false
Accept-Encoding: gzip
Authorization: GoogleLogin auth=null
User-Agent: MyApp/1.0 Google-HTTP-Java-Client/1.6.0-beta (gzip)
GData-Version: 2

Where in the Sam Hill did all that crap来自?但你知道吗?该 URL 在我的浏览器中仍然有效。这必须与 Authorization: 标头有关。

经过一番痛苦之后,我设法修改了示例中的身份验证,以便出现通知并允许用户对帐户进行身份验证。现在我可以列出专辑了。

但我还是不明白:如何在没有认证的情况下列出公开相册?

I'm having a terrible time accessing Picasa from Android. After hours of researching, I finally determined that the Google API Java Client library is what I should be using. Several hours later and I divined that I have to use Mercurial and Maven to download and build a sample client so that I can get certain secret libraries that aren't included in the download instructions. And of course the sample client is in no way compatible with and only slightly resembles that in the Picasa Developer's Guide.

So after much trouble I create a simple URL and try to list albums for a user, using code from the sample client:

PicasaUrl url = PicasaUrl.relativeToRoot("feed/api/user/someuser");
UserFeed userFeed = client.executeGetUserFeed(url);

Now the actual URL this creates is something like:

https://picasaweb.google.com/data/feed/api/user/someuser?prettyprint=true

If I put this in my browser, it works fine. In my Android client, however, it gives me an HTTP 403 forbidden error. And no, I can't even run the sample client, because it doesn't give me an APK file. (Plus the source code isn't documented, is written like spaghetti, and uses deprecated methods.)

After turning on protocol-level logging, it turns out that this is the HTTP request being sent:

GET https://picasaweb.google.com/data/feed/api/user/someuser?fields=author/name,entry(@gd:etag,category(@scheme,@term),gphoto:access,gphoto:numphotos,link(@href,@rel),summary,title,updated),link(@href,@rel),openSearch:totalResults&kinds=album&max-results=3&prettyprint=false
Accept-Encoding: gzip
Authorization: GoogleLogin auth=null
User-Agent: MyApp/1.0 Google-HTTP-Java-Client/1.6.0-beta (gzip)
GData-Version: 2

Where in the Sam Hill did all that crap come from? But you know what? The URL still works in my browser. This must be something about the Authorization: header.

After much more pain, I managed to modify the authentication from the sample so that a notification would appear and allow the user to authenticate the account. Now I'm able to list albums.

But I still don't understand: how can I list the public albums without authentication?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文