public static OAuth20Token Auth(HttpContext context, string scopes)
        {
            var error = context.Request["error"];
            if (!string.IsNullOrEmpty(error))
            {
                if (error == "access_denied")
                {
                    error = "Canceled at provider";
                }
                throw new Exception(error);
            }

            var code = context.Request["code"];
            if (string.IsNullOrEmpty(code))
            {
                var additionalArgs =
                    (context.Request["access_type"] ?? "") == "offline"
                        ? new Dictionary<string, string>
                            {
                                {"access_type", "offline"},
                                {"approval_prompt", "force"}
                            }
                        : null;

                OAuth20TokenHelper.RequestCode(HttpContext.Current,
                                               GoogleOauthCodeUrl,
                                               GoogleOAuth20ClientId,
                                               GoogleOAuth20RedirectUrl,
                                               scopes,
                                               additionalArgs);
                return null;
            }

            var token = OAuth20TokenHelper.GetAccessToken(GoogleOauthTokenUrl,
                                                          GoogleOAuth20ClientId,
                                                          GoogleOAuth20ClientSecret,
                                                          GoogleOAuth20RedirectUrl,
                                                          code);
            return token;
        }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                var error = Request["error"];
                if (!string.IsNullOrEmpty(error))
                {
                    if (error == "access_denied")
                    {
                        error = "Canceled at provider";
                    }
                    throw new Exception(error);
                }

                var code = Request["code"];
                if (string.IsNullOrEmpty(code))
                {
                    OAuth20TokenHelper.RequestCode <GoogleLoginProvider>(HttpContext.Current,
                                                                         string.Concat(GoogleLoginProvider.GoogleScopeMail, " ", GoogleLoginProvider.Instance.Scopes),
                                                                         new Dictionary <string, string>
                    {
                        { "access_type", "offline" },
                        { "prompt", "consent" }
                    });
                }
                else
                {
                    SubmitData(code);
                }
            }
            catch (ThreadAbortException)
            {
            }
            catch (Exception ex)
            {
                SubmitData(null, ex.Message);
            }
        }
        protected virtual OAuth20Token Auth(HttpContext context, string scopes, Dictionary <string, string> additionalArgs = null)
        {
            var error = context.Request.Query["error"];

            if (!string.IsNullOrEmpty(error))
            {
                if (error == "access_denied")
                {
                    error = "Canceled at provider";
                }
                throw new Exception(error);
            }

            var code = context.Request.Query["code"];

            if (string.IsNullOrEmpty(code))
            {
                OAuth20TokenHelper.RequestCode <T>(context, ConsumerFactory, scopes, additionalArgs);
                return(null);
            }

            return(OAuth20TokenHelper.GetAccessToken <T>(ConsumerFactory, code));
        }
Beispiel #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                var error = Request["error"];
                if (!string.IsNullOrEmpty(error))
                {
                    if (error == "access_denied")
                    {
                        error = "Canceled at provider";
                    }
                    throw new Exception(error);
                }

                var code = Request["code"];
                if (string.IsNullOrEmpty(code))
                {
                    OAuth20TokenHelper.RequestCode <DocuSignLoginProvider>(HttpContext.Current,
                                                                           DocuSignLoginProvider.Instance.Scopes,
                                                                           new Dictionary <string, string>
                    {
                        { "prompt", "login" }
                    });
                }
                else
                {
                    Master.SubmitCode(code);
                }
            }
            catch (ThreadAbortException)
            {
            }
            catch (Exception ex)
            {
                Master.SubmitError(ex.Message);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                var error = Request["error"];
                if (!string.IsNullOrEmpty(error))
                {
                    if (error == "access_denied")
                    {
                        error = "Canceled at provider";
                    }
                    throw new Exception(error);
                }

                var code = Request["code"];
                if (string.IsNullOrEmpty(code))
                {
                    OAuth20TokenHelper.RequestCode <DropboxLoginProvider>(HttpContext.Current,
                                                                          additionalArgs: new Dictionary <string, string>
                    {
                        { "force_reauthentication", "true" },
                        { "token_access_type", "offline" }
                    });
                }
                else
                {
                    Master.SubmitCode(code);
                }
            }
            catch (ThreadAbortException)
            {
            }
            catch (Exception ex)
            {
                Master.SubmitError(ex.Message);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                var error = Request["error"];
                if (!string.IsNullOrEmpty(error))
                {
                    if (error == "access_denied")
                    {
                        error = "Canceled at provider";
                    }
                    throw new Exception(error);
                }

                var code = Request["code"];
                if (string.IsNullOrEmpty(code))
                {
                    OAuth20TokenHelper.RequestCode(HttpContext.Current,
                                                   OneDriveLoginProvider.OneDriveOauthCodeUrl,
                                                   OneDriveLoginProvider.OneDriveOAuth20ClientId,
                                                   OneDriveLoginProvider.OneDriveOAuth20RedirectUrl,
                                                   OneDriveLoginProvider.OneDriveProfileScope);
                }
                else
                {
                    Master.SubmitToken(code, Source);
                }
            }
            catch (ThreadAbortException)
            {
            }
            catch (Exception ex)
            {
                Master.SubmitError(ex.Message, Source);
            }
        }