ClientLogin for Picasa Web Albums Data API with Google App Domain login
I am using the Picasa Web Albums Data API to access users' photo albums from a WPF application.
I followed the code found here: http://code.google.com/apis/gdata/clientlogin.html
I created a Picasa Web Albums account with my Google Apps (hosting) account. Whenever I tried to log in with my WPF application, I get back the "BadAuthentication" error code.
Hoping that someone knows what I am doing wrong. Please note that this works when I am logged in with a regular 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();
a source to share
After playing around a bit, I changed AccountType = "GOOGLE"
and it worked.
Thinking about it, it makes sense. I created an account using an existing email address. So in this situation, I was logging into a google account and not a hosted account.
Initially I did not specify RequestFactory
, so the code looked like this:
_picasaService = new PicasaService(_appName);
_picasaService.setUserCredentials(username, password);
return _picasaService.QueryAuthenticationToken();
This will result in an Invalid User error. I originally thought I needed to install AccountType = "HOSTED_OR_GOOGLE"
to get this to work. I had it in my head. So I added RequestFactory
, thinking it would solve my problems.
Have a look at the documentation for GDataGAuthRequestFactory . It claims AccountType
to be the default "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 it works. I must conclude that the registered default for AccountType
of "GOOGLE_OR_HOSTED"
is not correct.
a source to share