views:

915

answers:

2

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();

+1  A: 

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.

mlsteeves
I've submitted an issue report to the owners for the Google Data Api for .net: http://code.google.com/p/google-gdata/issues/detail?id=247
mlsteeves
A: 

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..

Open SEO