public function Client::checkAuth in Media: Acquia DAM 8
Authenticates with the DAM service and retrieves or uses an access token.
Return value
array An array of authentication token information.
Throws
\GuzzleHttp\Exception\GuzzleException
\cweagans\webdam\Exception\InvalidCredentialsException
See also
\Drupal\media_acquiadam\Client::getAuthState()
7 calls to Client::checkAuth()
- Client::downloadFromQueue in src/
Client.php - Gets asset download queue information.
- Client::editAsset in src/
Client.php - Edit an asset.
- Client::editAssetXmpMetadata in src/
Client.php - Edit asset XMP metadata.
- Client::getActiveXmpFields in src/
Client.php - Get a list of metadata.
- Client::getNotifications in src/
Client.php - Returns the list of recent Webdam REST API "Notifications".
File
- src/
Client.php, line 96
Class
- Client
- Overridden implementation of the cweagans php-webdam-client.
Namespace
Drupal\media_acquiadamCode
public function checkAuth() {
$is_expired_token = empty($this->accessTokenExpiry) || time() >= $this->accessTokenExpiry;
$is_expired_session = !empty($this->accessToken) && $is_expired_token;
// Session is still valid.
if (!empty($this->accessToken) && !$is_expired_token) {
return $this
->getAuthState();
}
elseif ($is_expired_session && !empty($this->refreshToken)) {
$data = [
'grant_type' => 'refresh_token',
'refresh_token' => $this->refreshToken,
'client_id' => $this->clientId,
'client_secret' => $this->clientSecret,
];
$this
->authenticate($data);
}
elseif ($this->manualToken) {
// @todo Why can't we authenticate after a manual set?
throw new InvalidCredentialsException('Cannot reauthenticate a manually set token.');
}
else {
$this
->authenticate();
}
return $this
->getAuthState();
}