diff --git a/FoxTube/MainPage.xaml b/FoxTube/MainPage.xaml index 5b220a2..69ad584 100644 --- a/FoxTube/MainPage.xaml +++ b/FoxTube/MainPage.xaml @@ -67,8 +67,8 @@ Width="50" Height="50" Background="#00000000" RelativePanel.LeftOf="searchField"> - - + + diff --git a/FoxTube/MainPage.xaml.cs b/FoxTube/MainPage.xaml.cs index 3ef8061..56eb055 100644 --- a/FoxTube/MainPage.xaml.cs +++ b/FoxTube/MainPage.xaml.cs @@ -20,6 +20,15 @@ using Windows.UI.Notifications; using Windows.UI.Xaml.Media.Imaging; using Windows.Storage; +using Google.Apis.Auth.OAuth2; +using Google.Apis.Services; +using Google.Apis.Upload; +using Google.Apis.YouTube.v3; +using Google.Apis.YouTube.v3.Data; +using System.Threading.Tasks; +using System.Threading; +using Google.Apis.Util.Store; + // The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409 namespace FoxTube @@ -284,5 +293,42 @@ namespace FoxTube { AccountManagement.IsOpen = true; } + + private void createAccount_Click(object sender, RoutedEventArgs e) + { + Process.Start("https://accounts.google.com/signup/"); + } + + private void signIn_Click(object sender, RoutedEventArgs e) + { + LogIn().Wait(); + } + + private async Task LogIn() + { + UserCredential credential; + StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri(@"ms-appx:///client_secrets.json")); + + Debug.WriteLine("Exception accured after opening a stream"); + + credential = await GoogleWebAuthorizationBroker.AuthorizeAsync( + GoogleClientSecrets.Load(await file.OpenStreamForReadAsync()).Secrets, + new[] { YouTubeService.Scope.Youtube }, + "user", + CancellationToken.None, + new FileDataStore(this.GetType().ToString()) + ); + Debug.WriteLine("200 OK"); + /*using (var stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read)) + { + credential = await GoogleWebAuthorizationBroker.AuthorizeAsync( + GoogleClientSecrets.Load(stream).Secrets, + new[] { YouTubeService.Scope.Youtube }, + "user", + CancellationToken.None, + new FileDataStore(this.GetType().ToString()) + ); + }*/ + } } }