public static string GetErrorRedirectUrl( string redirectUri, string error, string errorDescription, string state, OAuth2UrlParamLocation location) => GetUri(redirectUri, new Dictionary <string, string> { ["error"] = error, ["error_description"] = errorDescription, ["state"] = state, }, location);
private static string GetUri(string baseUrl, IDictionary <string, string> queryParams, OAuth2UrlParamLocation location) { var query = QueryString.Create( queryParams.Where(queryParam => queryParam.Value != null)); var uriBuilder = new UriBuilder(baseUrl); if (location == OAuth2UrlParamLocation.Fragment) { uriBuilder.Fragment = query.ToString().TrimStart('?'); } else { uriBuilder.Query = query.ToString().TrimStart('?'); } return(uriBuilder.Uri.ToString()); }