-
Notifications
You must be signed in to change notification settings - Fork 1
/
MainPage.xaml.cs
57 lines (54 loc) · 1.79 KB
/
MainPage.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using UWStatsUWPLib;
using SpotifyAPI.Web;
using Windows.ApplicationModel.DataTransfer;
using static UWStatsUWPLib.SettingsProvider;
namespace UWStats
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
private async void Page_Loaded(object sender, RoutedEventArgs e)
{
if (Auth.isAuthorized)
{
this.Frame.Navigate(typeof(InterfacePage), AccessToken);
}
else
{
await ContentDialog1.ShowAsync();
DataPackage pkg = new DataPackage();
SettingsProvider.ClientID = ContentDialog1.Tag.ToString();
(string verifier, string challenge) = Auth.VerifierAndChallenge;
var loginRequest = new LoginRequest(
new Uri("http://localhost:5543/callback"),
SettingsProvider.ClientID,
LoginRequest.ResponseType.Code
)
{
CodeChallengeMethod = "S256",
CodeChallenge = challenge,
Scope = new[] { Scopes.UserTopRead, Scopes.UserReadEmail, Scopes.UserReadPrivate }
};
var uri = loginRequest.ToUri();
this.Frame.Navigate(typeof(AuthWebPage), uri);
}
}
}
}