public Task<HttpResponseMessage> ExecuteAsync(CancellationToken cancellationToken) { HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.Redirect); UriBuilder uriBuilder = new UriBuilder(new Uri(Request.RequestUri, RedirectUrl)); FormUrlEncodedStringBuilder fragmentBuilder = new FormUrlEncodedStringBuilder(); fragmentBuilder.Add("error", GetErrorText(Response.Error)); if (!String.IsNullOrEmpty(Response.ErrorDescription)) { fragmentBuilder.Add("error_description", Response.ErrorDescription); } if (!String.IsNullOrEmpty(Response.ErrorUri)) { fragmentBuilder.Add("error_uri", Response.ErrorUri); } if (!String.IsNullOrEmpty(Response.State)) { fragmentBuilder.Add("state", Response.State); } uriBuilder.Fragment = fragmentBuilder.Build(); response.Headers.Location = uriBuilder.Uri; response.RequestMessage = Request; return Task.FromResult(response); }
public Task<HttpResponseMessage> ExecuteAsync(CancellationToken cancellationToken) { HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.Redirect); UriBuilder uriBuilder = new UriBuilder(new Uri(Request.RequestUri, RedirectUrl)); FormUrlEncodedStringBuilder fragmentBuilder = new FormUrlEncodedStringBuilder(); fragmentBuilder.Add("access_token", Response.AccessToken); fragmentBuilder.Add("token_type", Response.TokenType); if (Response.ExpiresIn.HasValue) { fragmentBuilder.Add("expires_in", Response.ExpiresIn.Value.ToString(CultureInfo.InvariantCulture)); } if (!String.IsNullOrEmpty(Response.Scope)) { fragmentBuilder.Add("scope", Response.Scope); } if (!String.IsNullOrEmpty(Response.State)) { fragmentBuilder.Add("state", Response.State); } uriBuilder.Fragment = fragmentBuilder.Build(); response.Headers.Location = uriBuilder.Uri; response.RequestMessage = Request; return Task.FromResult(response); }