public function PardotClient::authenticate in Pardot Integration 2.x
Authenticate into Pardot API and return the API Key.
API keys are saved and reused for 50 minutes.
Parameters
array $refresh: if we are getting a new token
Return value
null|string API key, if found. NULL on failure.
Overrides PardotClientInterface::authenticate
2 calls to PardotClient::authenticate()
- PardotClient::buildDefaultPostData in src/
Service/ PardotClient.php - Build the default post data used by most service operations.
- PardotClient::retry in src/
Service/ PardotClient.php - Retry the original operation with fresh token.
File
- src/
Service/ PardotClient.php, line 147
Class
- PardotClient
- Provides methods to execute Pardot API operations.
Namespace
Drupal\pardot\ServiceCode
public function authenticate($refresh = FALSE) {
if ($this
->isInit()) {
$token = $this->authToken
->getAccessToken();
if ($refresh) {
try {
$token = $this->authProvider
->authManager()
->refreshToken()
->getAccessToken();
} catch (\Exception $e) {
$this->logger
->error("Pardot API could not refesh token.");
return FALSE;
}
}
if ($token) {
return $token;
}
}
return NULL;
}