You are here

public function Client::__construct in OAuth2 Client 7.2

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

Construct an OAuth2\Client object.

Parameters

array $params: Associative array of the parameters that are needed by the different types of authorization flows.

string $id: ID of the client. If not given, it will be generated from token_endpoint, client_id and auth_flow.

File

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

Class

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

Namespace

OAuth2

Code

public function __construct(array $params = NULL, $id = NULL) {
  if ($params) {
    $this->params = $params + $this->params;
  }
  if (!$id) {
    $id = md5($this->params['token_endpoint'] . $this->params['client_id'] . $this->params['auth_flow']);
  }
  $this->id = $id;

  // Get the token data from the storage, if exists.
  $this->token = static::loadToken($this->id);
}