Exemplo n.º 1
0
        public bool ShowAuthorizationDialog(bool isModal)
        {
            logger.Debug("ShowAuthorizationDialog {0}", isModal);
            string         sAuthorizationURL = OAuthUtil.CreateOAuth2AuthorizationUrl(AuthParams);
            GoogleAuthForm fAuthForm         = new GoogleAuthForm();

            fAuthForm.Url = sAuthorizationURL;
            if (isModal)
            {
                fAuthForm.ShowDialog();
            }
            else
            {
                fAuthForm.Show();
            }
            AuthResult arAuthResult = fAuthForm.Result ?? new AuthResult()
            {
                Result = ResultType.Denied, Value = string.Empty
            };

            logger.Info("Authorization Result={0}, Value={1}", arAuthResult.Result, arAuthResult.Value);

            if (arAuthResult.Result == ResultType.Success)
            {
                AuthParams.AccessCode = arAuthResult.Value;
                OAuthUtil.GetAccessToken(AuthParams);

                SaveAuthParams();

                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
        public bool ShowAuthorizationDialog(bool isModal)
        {
            logger.Debug("ShowAuthorizationDialog {0}", isModal);
            string sAuthorizationURL = OAuthUtil.CreateOAuth2AuthorizationUrl(AuthParams);
            GoogleAuthForm fAuthForm = new GoogleAuthForm();
            fAuthForm.Url = sAuthorizationURL;
            if (isModal)
            {
                fAuthForm.ShowDialog();
            }
            else
            {
                fAuthForm.Show();
            }
            AuthResult arAuthResult = fAuthForm.Result ?? new AuthResult() { Result = ResultType.Denied, Value = string.Empty };
            logger.Info("Authorization Result={0}, Value={1}", arAuthResult.Result, arAuthResult.Value);

            if (arAuthResult.Result == ResultType.Success)
            {
                AuthParams.AccessCode = arAuthResult.Value;
                OAuthUtil.GetAccessToken(AuthParams);

                SaveAuthParams();

                return true;
            }

            return false;
        }