You are here

private function BaseApiAbstract::checkAuthenticationError in TMGMT Translator Smartling 8.3

Same name and namespace in other branches
  1. 8.4 vendor/smartling/api-sdk-php/src/BaseApiAbstract.php \Smartling\BaseApiAbstract::checkAuthenticationError()
  2. 8.2 api-sdk-php/src/BaseApiAbstract.php \Smartling\BaseApiAbstract::checkAuthenticationError()
  3. 8.2 vendor/smartling/api-sdk-php/src/BaseApiAbstract.php \Smartling\BaseApiAbstract::checkAuthenticationError()

Parameters

Response $response:

Throws

SmartlingApiException

1 call to BaseApiAbstract::checkAuthenticationError()
BaseApiAbstract::sendRequest in vendor/smartling/api-sdk-php/src/BaseApiAbstract.php

File

vendor/smartling/api-sdk-php/src/BaseApiAbstract.php, line 358

Class

BaseApiAbstract
Class BaseApiAbstract

Namespace

Smartling

Code

private function checkAuthenticationError(Response $response) {

  //Special handling for 401 error - authentication error => expire token
  if (401 === (int) $response
    ->getStatusCode()) {
    if (!$this
      ->getAuth() instanceof AuthApiInterface) {
      $type = gettype($this
        ->getAuth());
      if ('object' === $type) {
        $type .= '::' . get_class($this
          ->getAuth());
      }
      throw new SmartlingApiException('AuthProvider expected to be instance of AuthApiInterface, type given:' . $type, 401);
    }
    else {
      $this
        ->getAuth()
        ->resetToken();
    }
  }
}