title: picasaweb.google.com OAuth 2.0
body: <p>We have a problem with the new authentication PicasaWeb</p>
  
  <p>We are using this code in C # .NET 2012 ( Framework 4.5.1 )</p>
  
  <pre><code>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);
  </code></pre>
  
  <p>We have an error to retrieve the PicasaFeed : 
  Unhandled Exception: Google.GData.Client.GDataRequestException: Execution of aut hentication request returned unexpected result: 404</p>
  
  <p>We've done every step of the link : <a href="https://stackoverflow.com/questions/30469058/google-gdata-client-gdatarequestexception-authentication-suddenly-fails-in-old">Google.GData.Client.GDataRequestException - Authentication suddenly fails in old code</a>
  But it has not worked , is that we are using 4.5.1 and not 4.5 ?</p>
  
  <p>We have done some testing generating the token from the page of Google : <a href="https://developers.google.com/oauthplayground" rel="nofollow noreferrer">https://developers.google.com/oauthplayground</a></p>
  
  <p>We selected Picasa Web API v2 with the scope: <a href="https://picasaweb.google.com/data/" rel="nofollow noreferrer">https://picasaweb.google.com/data/</a></p>
  
  <p>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 :</p>
  
  <pre><code>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);
  </code></pre>
  
  <p>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?</p>
  
  <p>Thank you very much</p>