使用 Google 应用程序域登录的 Picasa 网络相册数据 API 的 ClientLogin

发布于 2024-07-21 03:03:14 字数 773 浏览 4 评论 0原文

我正在使用 Picasa 网络相册数据 API 从 WPF 应用程序访问用户的相册。

我已按照此处的代码进行操作: http://code.google.com/apis/gdata/clientlogin.html

我已使用 Google Apps(托管)帐户创建了 Picasa 网络相册帐户。 每当我尝试使用 WPF 应用程序登录时,都会返回“BadAuthentication”错误代码。

希望有人知道我做错了什么。 请注意,当我使用普通的 Google 帐户登录时,这才有效。

这是我的代码片段:


GDataGAuthRequestFactory authFactory = new GDataGAuthRequestFactory("lh2", _appName);
authFactory.AccountType = "HOSTED_OR_GOOGLE";

_picasaService = new PicasaService(authFactory.ApplicationName);
_picasaService.RequestFactory = authFactory;

_picasaService.setUserCredentials(username, password);
return _picasaService.QueryAuthenticationToken();

I'm using the Picasa Web Albums Data API to access users' photo albums from a WPF application.

I've followed the code located here:
http://code.google.com/apis/gdata/clientlogin.html

I have created a Picasa Web Albums account with a Google Apps (hosted) account. Whenever I tried logging in with my WPF application, I get the "BadAuthentication" error code returned.

Hoping someone has an idea what I'm doing wrong. Note, that this works when I login with a normal Google account.

Here is a snippet of my code:


GDataGAuthRequestFactory authFactory = new GDataGAuthRequestFactory("lh2", _appName);
authFactory.AccountType = "HOSTED_OR_GOOGLE";

_picasaService = new PicasaService(authFactory.ApplicationName);
_picasaService.RequestFactory = authFactory;

_picasaService.setUserCredentials(username, password);
return _picasaService.QueryAuthenticationToken();

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

煮茶煮酒煮时光 2024-07-28 03:03:14

经过一番尝试后,我更改了 AccountType = "GOOGLE",结果成功了。

想想也是有道理的。 我使用现有的电子邮件地址创建了该帐户。 所以在这种情况下,我登录的是 Google 帐户,而不是托管帐户。

最初,我没有指定 RequestFactory,因此代码如下所示:


_picasaService = new PicasaService(_appName);

_picasaService.setUserCredentials(username, password);
return _picasaService.QueryAuthenticationToken();

这将导致“无效用户”错误。 我最初认为我需要设置 AccountType = "HOSTED_OR_GOOGLE" 才能使其正常工作。 我脑子里就有这个。 所以我添加了 RequestFactory,认为这可以解决我的问题。

查看 GDataGAuthRequestFactory 的文档。 它指出 AccountType 默认为 “GOOGLE_OR_HOSTED”,因此我尝试了以下代码:

GDataGAuthRequestFactory authFactory = new GDataGAuthRequestFactory("lh2", _appName);
authFactory.AccountType = "GOOGLE_OR_HOSTED";

_picasaService = new PicasaService(authFactory.ApplicationName);
_picasaService.RequestFactory = authFactory;

并且有效。 我必须得出结论,记录的 AccountType 的默认值 “GOOGLE_OR_HOSTED” 不正确。

After playing around a bit, I changed the AccountType = "GOOGLE", and that worked.

Thinking about it, that makes sense. I created the account using an existing email address. So in this situation, I was logging into the Google account, not the hosted account.

Originally, I had not specified a RequestFactory, so the code looked like this:


_picasaService = new PicasaService(_appName);

_picasaService.setUserCredentials(username, password);
return _picasaService.QueryAuthenticationToken();

This would cause a "Invalid User" error. I originally thought that I would need to set the AccountType = "HOSTED_OR_GOOGLE", to get this to work. I had that in my head. So I added the RequestFactory, thinking that would solve my problems.

Looking at the documentation for GDataGAuthRequestFactory. It states that the AccountType is defaulted to "GOOGLE_OR_HOSTED", so I tried this code:

GDataGAuthRequestFactory authFactory = new GDataGAuthRequestFactory("lh2", _appName);
authFactory.AccountType = "GOOGLE_OR_HOSTED";

_picasaService = new PicasaService(authFactory.ApplicationName);
_picasaService.RequestFactory = authFactory;

And that works. I have to conclude that the documented default value for AccountType of "GOOGLE_OR_HOSTED" is not correct.

我很坚强 2024-07-28 03:03:14

HOSTED 表示 Google Apps 帐户,GOOGLE 表示 Google 帐户。
你必须自己决定,这不完全是文档中的错误..

HOSTED means a Google Apps account, GOOGLE means a Google Account.
You have to decide on your own, this isn't exactly a bug in documentation..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文