public void ApplyRedirect(GoogleOAuth2ApplyRedirectContext context)
 {
     //context.Properties.IsPersistent = true;
     //string destination = context.RedirectUri.Split('&')[2].Split('=')[1];
     //string redirectUrl = "http%3A%2F%2Flocalhost:63000%2Fapi%2FAccounts%2FSocialLoginCallback";
     //context.RedirectUri.Replace(destination, redirectUrl);
     // context.Response.Headers["Access-Control-Allow-Origin"] = "*";
     context.Response.Redirect("http://localhost:4200"); //context.RedirectUri
 }
 public void ApplyRedirect(GoogleOAuth2ApplyRedirectContext context)
 {
     context.Response.Redirect(context.RedirectUri);
 }
Exemple #3
0
 public void ApplyRedirect(GoogleOAuth2ApplyRedirectContext context)
 {
     context.Response.Redirect(context.RedirectUri);
 }
 public void ApplyRedirect(GoogleOAuth2ApplyRedirectContext context)
 {
     context.Response.Redirect(context.RedirectUri+ "&approval_prompt=auto");
 }
 /// <summary>
 /// Called when a Challenge causes a redirect to authorize endpoint in the Google OAuth 2.0 middleware
 /// </summary>
 /// <param name="context">Contains redirect URI and <see cref="AuthenticationProperties"/> of the challenge </param>
 public virtual void ApplyRedirect(GoogleOAuth2ApplyRedirectContext context)
 {
     OnApplyRedirect(context);
 }
        protected override Task ApplyResponseChallengeAsync()
        {
            if (Response.StatusCode != 401)
            {
                return(Task.FromResult <object>(null));
            }

            AuthenticationResponseChallenge challenge = Helper.LookupChallenge(Options.AuthenticationType, Options.AuthenticationMode);

            if (challenge != null)
            {
                string baseUri =
                    Request.Scheme +
                    Uri.SchemeDelimiter +
                    Request.Host +
                    Request.PathBase;

                string currentUri =
                    baseUri +
                    Request.Path +
                    Request.QueryString;

                string redirectUri =
                    baseUri +
                    Options.CallbackPath;

                AuthenticationProperties properties = challenge.Properties;
                if (string.IsNullOrEmpty(properties.RedirectUri))
                {
                    properties.RedirectUri = currentUri;
                }

                // OAuth2 10.12 CSRF
                GenerateCorrelationId(properties);

                var queryStrings = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
                queryStrings.Add("response_type", "code");
                queryStrings.Add("client_id", Options.ClientId);
                queryStrings.Add("redirect_uri", redirectUri);

                // space separated
                string scope = string.Join(" ", Options.Scope);
                if (string.IsNullOrEmpty(scope))
                {
                    // Google OAuth 2.0 asks for non-empty scope. If user didn't set it, set default scope to
                    // "openid profile email" to get basic user information.
                    scope = "openid profile email";
                }
                AddQueryString(queryStrings, properties, "scope", scope);

                AddQueryString(queryStrings, properties, "access_type", Options.AccessType);
                AddQueryString(queryStrings, properties, "approval_prompt");
                AddQueryString(queryStrings, properties, "login_hint");

                string state = Options.StateDataFormat.Protect(properties);
                queryStrings.Add("state", state);

                string authorizationEndpoint = WebUtilities.AddQueryString(AuthorizeEndpoint,
                                                                           queryStrings);

                var redirectContext = new GoogleOAuth2ApplyRedirectContext(
                    Context, Options,
                    properties, authorizationEndpoint);
                Options.Provider.ApplyRedirect(redirectContext);
            }

            return(Task.FromResult <object>(null));
        }
 void IGoogleOAuth2AuthenticationProvider.ApplyRedirect(GoogleOAuth2ApplyRedirectContext context)
 {
     context.Response.Redirect(context.RedirectUri);
 }