internal void AcquireAuthorization()
        {
            var sendAuthorizeRequest = new Action(
                delegate
                {
                    Uri authorizationUri = this.CreateAuthorizationUri(IncludeFormsAuthParams());
                    string resultUri = this.webUi.Authenticate(authorizationUri, this.redirectUri);
                    this.authorizationResult = OAuth2Response.ParseAuthorizeResponse(resultUri, this.CallState);
                });

            // If the thread is MTA, it cannot create or communicate with WebBrowser which is a COM control.
            // In this case, we have to create the browser in an STA thread via StaTaskScheduler object.
            if (Thread.CurrentThread.GetApartmentState() == ApartmentState.MTA)
            {
                using (var staTaskScheduler = new StaTaskScheduler(1))
                {
                    Task.Factory.StartNew(sendAuthorizeRequest, CancellationToken.None, TaskCreationOptions.None, staTaskScheduler).Wait();
                }
            }
            else
            {
                sendAuthorizeRequest();
            }
        }
        internal void AcquireAuthorization()
        {
            var sendAuthorizeRequest = new Action(
                delegate
            {
                Uri authorizationUri     = this.CreateAuthorizationUri(IncludeFormsAuthParams());
                string resultUri         = this.webUi.Authenticate(authorizationUri, this.redirectUri);
                this.authorizationResult = OAuth2Response.ParseAuthorizeResponse(resultUri, this.CallState);
            });

            // If the thread is MTA, it cannot create or communicate with WebBrowser which is a COM control.
            // In this case, we have to create the browser in an STA thread via StaTaskScheduler object.
            if (Thread.CurrentThread.GetApartmentState() == ApartmentState.MTA)
            {
                using (var staTaskScheduler = new StaTaskScheduler(1))
                {
                    Task.Factory.StartNew(sendAuthorizeRequest, CancellationToken.None, TaskCreationOptions.None, staTaskScheduler).Wait();
                }
            }
            else
            {
                sendAuthorizeRequest();
            }
        }