Created
July 15, 2015 19:09
-
-
Save angelovstanton/13b81a73d3f955780569 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private async Task<YouTubeService> GetYouTubeService(string userEmail) | |
{ | |
UserCredential credential; | |
using (var stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read)) | |
{ | |
credential = await GoogleWebAuthorizationBroker.AuthorizeAsync( | |
GoogleClientSecrets.Load(stream).Secrets, | |
new[] | |
{ | |
YouTubeService.Scope.Youtube, | |
YouTubeService.Scope.Youtubepartner, | |
YouTubeService.Scope.YoutubeUpload, | |
YouTubeService.Scope.YoutubepartnerChannelAudit, | |
YouTubeService.Scope.YoutubeReadonly | |
}, | |
userEmail, | |
CancellationToken.None, | |
new FileDataStore(this.GetType().ToString())); | |
} | |
var youtubeService = new YouTubeService(new BaseClientService.Initializer() | |
{ | |
HttpClientInitializer = credential, | |
ApplicationName = this.GetType().ToString() | |
}); | |
return youtubeService; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment