/** * Builds the URL to login process. * * @param string $endpoint_url The endpoint. Normally the 'authorization_endpoint' of * OAuth server. * @param string $redirect_url Where the user will be redirected, even on success or * not. * @param string $scope Section-key identifier of the web client. The * section-key is located in "oauthconf.xml" file. * @param string $social Social - to force login with social network. Optional. Values 'facebook', 'twitter' * @return string The URL generated. * @throws \Exception If there is an error. */ private static function buildLoginUrl($endpoint_url, $redirect_url, $scope = null, $social = null) { try { if (self::checkParam($endpoint_url)) { throw new Exception('Endpoint URL is empty'); } if (self::checkParam($redirect_url)) { throw new Exception('Redirect URL is empty'); } $endpoint_url = rtrim($endpoint_url, '?'); $params = array(); $params['client_id'] = OAuthConfig::getClientid(); $params['redirect_uri'] = $redirect_url; $params['response_type'] = 'code'; if (!is_null($scope)) { $params['scope'] = $scope; } if ($social != null) { $params['ck_auth_provider'] = $social; } return $endpoint_url . '?' . http_build_query($params, null, '&'); } catch (Exception $e) { Identity::getLogger()->debug('Error [' . __FUNCTION__ . '] - ' . $e->getMessage()); } }