Wednesday, January 8, 2014

Snippet Code to Get OAuth2 token from Google Blogger V3 / Picasa API

string[] scopes = new[] { BloggerService.Scope.Blogger, @"https://picasaweb.google.com/data/" };

// string[] scopes = new[] { BloggerService.Scope.Blogger };

try



{
 
using (var stream = new System.IO.FileStream("client_secrets.json", System.IO.FileMode.Open, System.IO.FileAccess.Read))



{
 
CancellationToken = new CancellationToken();

Credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(

GoogleClientSecrets.Load(stream).Secrets,

scopes, //new[] { BloggerService.Scope.Blogger },

"user",

CancellationToken.None);



}
 
string picasaURL = CreatePublicGalleryUrlRequest(Credential.Token.AccessToken);

await GetAlbums(picasaURL);

No comments:

Post a Comment