使用 Google 应用程序域登录的 Picasa 网络相册数据 API 的 ClientLogin
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
经过一番尝试后,我更改了
AccountType = "GOOGLE"
,结果成功了。想想也是有道理的。 我使用现有的电子邮件地址创建了该帐户。 所以在这种情况下,我登录的是 Google 帐户,而不是托管帐户。
最初,我没有指定
RequestFactory
,因此代码如下所示:这将导致“无效用户”错误。 我最初认为我需要设置
AccountType = "HOSTED_OR_GOOGLE"
才能使其正常工作。 我脑子里就有这个。 所以我添加了RequestFactory
,认为这可以解决我的问题。查看 GDataGAuthRequestFactory 的文档。 它指出
AccountType
默认为“GOOGLE_OR_HOSTED”
,因此我尝试了以下代码:并且有效。 我必须得出结论,记录的
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: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 theRequestFactory
, 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:And that works. I have to conclude that the documented default value for
AccountType
of"GOOGLE_OR_HOSTED"
is not correct.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..