83     public function __construct(
Platform $platform, array $scopes = null, 
string $token = null, 
int $expires = null)
    90         if (!empty($expires)) {
    93         $this->created = null;
    94         $this->updated = null;
   117         return $this->platform->getDataConnector()->loadAccessToken($this);
   128         return $this->platform->getDataConnector()->saveAccessToken($this);
   138         if (substr(
$scope, -9) === 
'.readonly') {
   139             $scope2 = substr(
$scope, 0, -9);
   143         return !empty($this->token) && (empty($this->expires) || ($this->expires > time())) &&
   144             (empty(
$scope) || empty($this->scopes) || (in_array(
$scope, $this->scopes) || in_array($scope2, $this->scopes)));
   155         $url = $this->platform->accessTokenUrl;
   158                 $scopesRequested = array($scope);
   161                 if (substr($scope, -9) === 
'.readonly') {
   162                     $scope2 = substr($scope, 0, -9);
   166                 if (!empty($scope) && !in_array($scope, $scopesRequested) && !in_array($scope2, $scopesRequested)) {
   167                     $scopesRequested[] = 
$scope;
   170             if (!empty($scopesRequested)) {
   174                     $type = 
'application/x-www-form-urlencoded';
   176                         'grant_type' => 
'client_credentials',
   177                         'client_assertion_type' => 
'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',
   178                         'scope' => implode(
' ', $scopesRequested)
   184                         $body = $this->platform->signServiceRequest(
$url, $method, $type, $body);
   186                     $http = 
new HttpMessage(
$url, $method, $body);
   187                     if (
$http->send() && !empty(
$http->response)) {
   188                         $http->responseJson = json_decode(
$http->response);
   189                         if (!is_null(
$http->responseJson) && !empty(
$http->responseJson->access_token) && !empty(
$http->responseJson->expires_in)) {
   190                             if (isset(
$http->responseJson->scope)) {
   191                                 $scopesAccepted = explode(
' ', 
$http->responseJson->scope);
   193                                 $scopesAccepted = $scopesRequested;
   195                             $this->scopes = $scopesAccepted;
   196                             $this->token = 
$http->responseJson->access_token;
   197                             $this->expires = time() + 
$http->responseJson->expires_in;
   205                     } elseif (!empty($scope) && (count($scopesRequested) > 1)) {  
   207                         $scopesRequested = array($scope);
   212             $this->scopes = null;
   214             $this->expires = null;
   215             $this->created = null;
   216             $this->updated = null;