You are here

protected function Client::getAuthenticationUrl in OAuth2 Client 7.2

Same name and namespace in other branches
  1. 7 oauth2_client.inc \OAuth2\Client::getAuthenticationUrl()

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

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

File

src/Client.php, line 357
Class OAuth2\Client.

Class

Client
The class OAuth2\Client is used to communicate with an oauth2 server.

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'];
  }
  if ($this->params['resource']) {
    $query_params['resource'] = $this->params['resource'];
  }
  $endpoint = $this->params['authorization_endpoint'];
  static::setRedirect($state);
  return $endpoint . '?' . http_build_query($query_params);
}