You are here

public function Client::__construct in OAuth2 Client 7

Same name and namespace in other branches
  1. 7.2 src/Client.php \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

./oauth2_client.inc, line 95
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

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);
}