You are here

protected function Client::getAuthenticationUrl in OAuth2 Client 7

Same name and namespace in other branches
  1. 7.2 src/Client.php \OAuth2\Client::getAuthenticationUrl()

Return the authentication url (used in case of the server-side flow).

1 call to Client::getAuthenticationUrl()
Client::getTokenServerSide in ./oauth2_client.inc
Get an access_token using the server-side (authorization code) flow.

File

./oauth2_client.inc, line 351
Class OAuth2\Client

Class

Client
The class OAuth2\Client is used to get authorization from an oauth2 server. Its only goal is to get an access_token from the oauth2 server, so the only public function (besides the constructor) is getAccessToken().

Namespace

OAuth2

Code

protected function getAuthenticationUrl() {
  $state = md5(uniqid(rand(), TRUE));
  $query_params = array(
    'response_type' => 'code',
    'client_id' => $this->params['client_id'],
    'redirect_uri' => $this->params['redirect_uri'],
    'state' => $state,
  );
  if ($this->params['scope']) {
    $query_params['scope'] = $this->params['scope'];
  }
  $endpoint = $this->params['authorization_endpoint'];
  static::setRedirect($state);
  return $endpoint . '?' . http_build_query($query_params);
}