1

We have a problem with the new authentication PicasaWeb

We are using this code in C # .NET 2012 ( Framework 4.5.1 )

const string ServiceAccountEmail = "xxxxxxxxxxxxxxxxxxxx@developer.gserviceaccount.com";
var certificate = new X509Certificate2(@"C:\key.p12", "notasecret", X509KeyStorageFlags.Exportable);
var serviceAccountCredentialInitializer =
new ServiceAccountCredential.Initializer(ServiceAccountEmail)
{
    Scopes = new[] { "https://picasaweb.google.com/data/"}
}.FromCertificate(certificate);
var credential = new ServiceAccountCredential(serviceAccountCredentialInitializer);
if (!credential.RequestAccessTokenAsync(System.Threading.CancellationToken.None).Result)
throw new InvalidOperationException("Access token request failed.");
var requestFactory = new GDataRequestFactory(null);
requestFactory.CustomHeaders.Add("Authorization: Bearer " + credential.Token.AccessToken);
requestFactory.CustomHeaders.Add("Gdata-version: 2");
PicasaService service = new PicasaService("api-project");
service.RequestFactory  = requestFactory;
PhotoQuery query = new PhotoQuery(PicasaQuery.CreatePicasaUri(_IdUsuari, _albumid));
PicasaFeed feed = service.Query(query);

We have an error to retrieve the PicasaFeed : Unhandled Exception: Google.GData.Client.GDataRequestException: Execution of aut hentication request returned unexpected result: 404

We've done every step of the link : Google.GData.Client.GDataRequestException - Authentication suddenly fails in old code But it has not worked , is that we are using 4.5.1 and not 4.5 ?

We have done some testing generating the token from the page of Google : https://developers.google.com/oauthplayground

We selected Picasa Web API v2 with the scope: https://picasaweb.google.com/data/

This has generated a token. We have marked the "Auto -refresh the token before it expires" option as it expires in 3600 seconds . The question is whether this token changes after 3600 seconds? . With the token generated from this link we have replaced the previous code , where " XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX " is the token generated :

var requestFactory = new GDataRequestFactory(null);
requestFactory.CustomHeaders.Add("Authorization: Bearer " + "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
requestFactory.CustomHeaders.Add("Gdata-version: 2");
PicasaService service = new PicasaService("api-project");
service.RequestFactory  = requestFactory;
PhotoQuery query = new PhotoQuery(PicasaQuery.CreatePicasaUri(_IdUsuari, _albumid));
PicasaFeed feed = service.Query(query);

And with this token if it works. Any thoughts that the first code generated by the token code is not working properly for generating tokens and readings to Picasa. Does anyone have any solution?

Thank you very much

Community
  • 1
  • 1
SIT FPT
  • 11
  • 3

1 Answers1

0

I only wanted to add, that I have the same problem since May, 25. Since then the api worked correctly and afterwords I get the 404 (page not found error) too.

Maybe google has changed something. Because my code look similar! and I don't see any error in your code.

Greetings Mike

Mike
  • 54
  • 1
  • 6