/** * Helper method to start the flow by redirecting the user to the * authentication server. The getAccessToken method must be used when the * server redirects the user back to the redirect uri * * @param \PSX\Url $url * @param string $clientId * @param string $redirectUri * @param string $scope * @param string $state */ 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()); }