コード例 #1
0
        private async void LogInButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            OAuthWebBrowserWindow oauthBrowser = new OAuthWebBrowserWindow(string.Format(TiltifyService.AuthorizationURL, TiltifyService.ClientID, TiltifyService.ListeningURL), TiltifyService.ListeningURL);

            oauthBrowser.Closed          += OauthBrowser_Closed;
            oauthBrowser.OnTokenAcquired += OauthBrowser_OnTokenAcquired;
            oauthBrowser.Show();

            while (!this.windowClosed && string.IsNullOrEmpty(this.authorizationToken))
            {
                await Task.Delay(500);
            }

            if (!string.IsNullOrEmpty(this.authorizationToken))
            {
                await this.viewModel.LogIn(this.authorizationToken);
            }
            this.authorizationToken = null;
        }
コード例 #2
0
        private async void LogInButton_Click(object sender, RoutedEventArgs e)
        {
            authorizationToken = null;
            windowClosed       = false;

            await this.groupBoxControl.window.RunAsyncOperation(async() =>
            {
                OAuthWebBrowserWindow oauthBrowser = new OAuthWebBrowserWindow(string.Format(TiltifyService.AuthorizationURL, TiltifyService.ClientID, TiltifyService.ListeningURL), TiltifyService.ListeningURL);
                oauthBrowser.Closed          += OauthBrowser_Closed;
                oauthBrowser.OnTokenAcquired += OauthBrowser_OnTokenAcquired;
                oauthBrowser.Show();

                while (!this.windowClosed && string.IsNullOrEmpty(this.authorizationToken))
                {
                    await Task.Delay(500);
                }

                if (!string.IsNullOrEmpty(this.authorizationToken))
                {
                    await ChannelSession.Services.InitializeTiltify(authorizationToken);
                }
            });

            if (ChannelSession.Services.Tiltify == null)
            {
                await MessageBoxHelper.ShowMessageDialog("Unable to authenticate with Tiltify. Please ensure you approved access for the application in a timely manner.");
            }
            else
            {
                await this.RefreshCampaigns();

                this.NewLoginGrid.Visibility        = Visibility.Collapsed;
                this.ExistingAccountGrid.Visibility = Visibility.Visible;

                this.SetCompletedIcon(visible: true);
            }
        }