protected override async Task <bool> HandleUnauthorizedAsync(ChallengeContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } var properties = new AuthenticationProperties(context.Properties) { ExpiresUtc = Options.SystemClock.UtcNow.Add(Options.RemoteAuthenticationTimeout) }; if (string.IsNullOrEmpty(properties.RedirectUri)) { properties.RedirectUri = CurrentUri; } // If CallbackConfirmed is false, this will throw var requestToken = await ObtainRequestTokenAsync(BuildRedirectUri(Options.CallbackPath), properties); var resource_url = ""; if (Options.UseDevelopmentUrls) { resource_url = AuthenticationDevEndpoint; } else { resource_url = AuthenticationEndpoint; } var openStreetmapAuthenticationEndpoint = resource_url + requestToken.Token; var cookieOptions = new CookieOptions { HttpOnly = true, Secure = Request.IsHttps }; Response.Cookies.Append(StateCookie, Options.StateDataFormat.Protect(requestToken), cookieOptions); var redirectContext = new OpenStreetMapRedirectToAuthorizationEndpointContext( Context, Options, properties, openStreetmapAuthenticationEndpoint); await Options.Events.RedirectToAuthorizationEndpoint(redirectContext); return(true); }
/// <summary> /// Called when a Challenge causes a redirect to authorize endpoint in the Twitter middleware /// </summary> /// <param name="context">Contains redirect URI and <see cref="Http.Authentication.AuthenticationProperties"/> of the challenge </param> public virtual Task RedirectToAuthorizationEndpoint(OpenStreetMapRedirectToAuthorizationEndpointContext context) => OnRedirectToAuthorizationEndpoint(context);