public function LingotekApi::getAccountInfo in Lingotek Translation 3.6.x
Same name and namespace in other branches
- 8 src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::getAccountInfo()
- 8.2 src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::getAccountInfo()
- 4.0.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::getAccountInfo()
- 3.0.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::getAccountInfo()
- 3.1.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::getAccountInfo()
- 3.2.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::getAccountInfo()
- 3.3.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::getAccountInfo()
- 3.4.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::getAccountInfo()
- 3.5.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::getAccountInfo()
- 3.7.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::getAccountInfo()
- 3.8.x src/Remote/LingotekApi.php \Drupal\lingotek\Remote\LingotekApi::getAccountInfo()
Get the account information.
Return value
array|bool Array with account info. FALSE in case of error. The keys are user_id, username, login_id, email, and name.
Overrides LingotekApiInterface::getAccountInfo
File
- src/
Remote/ LingotekApi.php, line 76
Class
- LingotekApi
- A simple connector to the Lingotek Translation API.
Namespace
Drupal\lingotek\RemoteCode
public function getAccountInfo() {
try {
$access_token = $this->lingotekClient
->getCurrentToken();
$trimmed_token = $access_token ? substr($access_token, 0, 8) . '…' : '';
$this->logger
->debug('Starting account info request: /auth/oauth2/access_token_info Token: %token', [
'%token' => $trimmed_token,
]);
$response = $this->lingotekClient
->get('/auth/oauth2/access_token_info');
} catch (\Exception $e) {
$this->logger
->error('Error requesting account info: %message.', [
'%message' => $e
->getMessage(),
]);
throw new LingotekApiException('Failed to get account info: ' . $e
->getMessage());
}
$this->logger
->debug('getAccountInfo response received, code %code and body %body', [
'%code' => $response
->getStatusCode(),
'%body' => (string) $response
->getBody(TRUE),
]);
return $response;
}