Started to implement an Google authentication
This commit is contained in:
@@ -67,8 +67,8 @@
|
||||
Width="50" Height="50" Background="#00000000" RelativePanel.LeftOf="searchField">
|
||||
<Button.Flyout>
|
||||
<MenuFlyout>
|
||||
<MenuFlyoutItem Text="Sign in with existing account"/>
|
||||
<MenuFlyoutItem Text="Create a new Google account"/>
|
||||
<MenuFlyoutItem Text="Sign in with existing account" Name="signIn" Click="signIn_Click"/>
|
||||
<MenuFlyoutItem Text="Create a new Google account" Name="createAccount" Click="createAccount_Click"/>
|
||||
</MenuFlyout>
|
||||
</Button.Flyout>
|
||||
</Button>
|
||||
|
||||
@@ -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())
|
||||
);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user