public function ClientFactory::get in Media: Acquia DAM 8
Creates a new DAM client object.
Parameters
string $credentials: The switch for which credentials the client object should be configured with.
Return value
\Drupal\media_acquiadam\Client A configured DAM HTTP client object.
File
- src/
ClientFactory.php, line 88
Class
- ClientFactory
- Class ClientFactory.
Namespace
Drupal\media_acquiadamCode
public function get($credentials = 'background') {
$client = $this
->getWithCredentials($this->config
->get('username'), $this->config
->get('password'), $this->config
->get('client_id'), $this->config
->get('secret'));
// Set the user's credentials in the client if necessary.
if ($credentials == 'current') {
$access_token = $this->userData
->get('media_acquiadam', $this->currentUser
->id(), 'acquiadam_access_token');
$access_token_expiration = $this->userData
->get('media_acquiadam', $this->currentUser
->id(), 'acquiadam_access_token_expiration');
$refresh_token = $this->userData
->get('media_acquiadam', $this->currentUser
->id(), 'acquiadam_refresh_token');
$client
->setToken($access_token, $access_token_expiration, $refresh_token);
}
return $client;
}