you postUri is wrong ,PicasaQuery.CreatePicasaUri(you email, you AlbumID) AlbumID find in picasaweb
I don‘t speak english 你的postUri 错误了,正确的类似: https://picasaweb.google.com/data/feed/api/user/[email protected] 我的代码和你的差不多,但是返回值为:403. 没有权限,但是用 OAuth 2.0 Playground 生成的 Access token 可以正常获取数据。 在 2015年5月29日星期五 UTC+8下午11:03:39,Ben Donovan写道: > > I have been using the picasa client login for a couple of years without > issue. We use it to store photos that users upload so we do not want to > request for user authentication as we are just storing the photos in our > own account. It is developed in .NET. > > > > Up until today it has worked and I can’t work out (and beginning to wander > whether it is now possible) how to fix the issue. > > > > *Previous Code:* > > > > PicasaService service = new PicasaService("My App"); > > service.setUserCredentials("[email protected] <javascript:>", "password"); > > > > Uri postUri = new Uri(PicasaQuery.CreatePicasaUri("default", AlbumID)); > > string sContentType = "image/jpeg"; > > > > > > PicasaEntry entry = (PicasaEntry)service.Insert(postUri, fileStream, > sContentType, sFilename); > > > > fileStream.Close(); > > > > sPicasaURL = entry.Media.Content.Url.ToString(); > > > > *NEW CODE (that doesn’t work!)* > > > > Uri postUri = new Uri(PicasaQuery.CreatePicasaUri("default", AlbumID)); > > > > const string ServiceAccountEmail = "[email protected] > <javascript:>"; > > > > var certificate = new X509Certificate2(HttpContext.Current.Server.MapPath( > "bin/key2.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); > > > > > > PicasaService service = new PicasaService("My App" > ... -- You received this message because you are subscribed to the Google Groups "Google Picasa Web Albums API" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/google-picasa-data-api. For more options, visit https://groups.google.com/d/optout.
