1

我正在使用 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();

4

2 回答 2

1

在玩了一会儿之后,我改变了AccountType = "GOOGLE", 并且奏效了。

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

最初,我没有指定 a 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我必须得出结论,记录的of的默认值"GOOGLE_OR_HOSTED"不正确。

于 2009-05-19T12:56:36.497 回答
0

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

于 2010-04-23T10:30:29.570 回答