public static async Task <MixerConnection> ConnectViaLocalhostOAuthBrowser(string clientID, string clientSecret, IEnumerable <OAuthClientScopeEnum> scopes, bool forceApprovalPrompt = false, string oauthListenerURL = DEFAULT_OAUTH_LOCALHOST_URL, string loginSuccessHtmlPageFilePath = null)
        {
            Validator.ValidateString(clientID, "clientID");
            Validator.ValidateList(scopes, "scopes");

            OAuthHttpListenerServer oauthServer = new OAuthHttpListenerServer(oauthListenerURL, loginSuccessHtmlPageFilePath);

            oauthServer.Start();

            string url = await MixerConnection.GetAuthorizationCodeURLForOAuthBrowser(clientID, scopes, oauthListenerURL, forceApprovalPrompt);

            ProcessStartInfo startInfo = new ProcessStartInfo()
            {
                FileName = url, UseShellExecute = true
            };

            Process.Start(startInfo);

            string authorizationCode = await oauthServer.WaitForAuthorizationCode();

            oauthServer.End();

            if (authorizationCode != null)
            {
                return(await MixerConnection.ConnectViaAuthorizationCode(clientID, clientSecret, authorizationCode, redirectUrl : oauthListenerURL));
            }
            return(null);
        }
        protected virtual async Task <string> ConnectViaOAuthRedirect(string oauthPageURL, string listeningAddress)
        {
            OAuthHttpListenerServer oauthServer = new OAuthHttpListenerServer(listeningAddress, loginSuccessHtmlPageFilePath: OAuthServiceBase.LoginRedirectPageFileName);

            oauthServer.Start();

            ProcessStartInfo startInfo = new ProcessStartInfo()
            {
                FileName = oauthPageURL, UseShellExecute = true
            };

            Process.Start(startInfo);

            string authorizationCode = await oauthServer.WaitForAuthorizationCode();

            oauthServer.End();

            return(authorizationCode);
        }