/// <summary>
    /// Executes the result.
    /// </summary>
    /// <param name="context">The HTTP context.</param>
    /// <returns></returns>
    public async Task ExecuteAsync(HttpContext context)
    {
        Init(context);

        var returnUrl = _urls.BasePath.EnsureTrailingSlash() + Constants.ProtocolRoutePaths.AuthorizeCallback;

        if (_authorizationParametersMessageStore != null)
        {
            var msg = new Message <IDictionary <string, string[]> >(_request.ToOptimizedFullDictionary());
            var id  = await _authorizationParametersMessageStore.WriteAsync(msg);

            returnUrl = returnUrl.AddQueryString(Constants.AuthorizationParamsStore.MessageStoreIdParameterName, id);
        }
        else
        {
            returnUrl = returnUrl.AddQueryString(_request.ToOptimizedQueryString());
        }

        if (!_url.IsLocalUrl())
        {
            // this converts the relative redirect path to an absolute one if we're
            // redirecting to a different server
            returnUrl = _urls.Origin + returnUrl;
        }

        var url = _url.AddQueryString(_options.UserInteraction.CustomRedirectReturnUrlParameter, returnUrl);

        context.Response.Redirect(_urls.GetAbsoluteUrl(url));
    }
        /// <summary>
        /// Executes the result.
        /// </summary>
        /// <param name="context">The HTTP context.</param>
        /// <returns></returns>
        public async Task ExecuteAsync(HttpContext context)
        {
            Init(context);

            var returnUrl = context.GetIdentityServerBasePath().EnsureTrailingSlash() + Constants.ProtocolRoutePaths.AuthorizeCallback;

            if (_authorizationParametersMessageStore != null)
            {
                var msg = new Message <IDictionary <string, string[]> >(_request.Raw.ToFullDictionary());
                var id  = await _authorizationParametersMessageStore.WriteAsync(msg);

                returnUrl = returnUrl.AddQueryString(Constants.AuthorizationParamsStore.MessageStoreIdParameterName, id);
            }
            else
            {
                returnUrl = returnUrl.AddQueryString(_request.Raw.ToQueryString());
            }

            var loginUrl = _options.UserInteraction.LoginUrl;

            if (!loginUrl.IsLocalUrl())
            {
                // this converts the relative redirect path to an absolute one if we're
                // redirecting to a different server
                returnUrl = context.GetIdentityServerHost().EnsureTrailingSlash() + returnUrl.RemoveLeadingSlash();
            }

            var url = loginUrl.AddQueryString(_options.UserInteraction.LoginReturnUrlParameter, returnUrl);

            context.Response.RedirectToAbsoluteUrl(url);
        }
        /// <inheritdoc/>
        public async Task <(string ReturnUrl, string OtherParameters)> StoreParametersAsync(ValidatedAuthorizeRequest request)
        {
            var otherParameters = string.Empty;

            if (_store != null)
            {
                var msg = new Message <IDictionary <string, string[]> >(request.Raw.ToFullDictionary());
                var id  = await _store.WriteAsync(msg);

                otherParameters = otherParameters.AddQueryString(Constants.AuthorizationParamsStore.MessageStoreIdParameterName, id);
            }
            else
            {
                otherParameters = otherParameters.AddQueryString(request.Raw.ToQueryString());
            }

            return(Constants.ProtocolRoutePaths.AuthorizeCallback, otherParameters);
        }