public static function redirect(Url $url, $clientId, $redirectUri = null, $scope = null, $state = null)
    {
        $parameters = $url->getParameters();
        $parameters['response_type'] = 'code';
        $parameters['client_id']     = $clientId;

        if (isset($redirectUri)) {
            $parameters['redirect_uri'] = $redirectUri;
        }

        if (isset($scope)) {
            $parameters['scope'] = $scope;
        }

        if (isset($state)) {
            $parameters['state'] = $state;
        }

        throw new StatusCode\TemporaryRedirectException($url->withScheme('https')->withParameters($parameters)->toString());
    }