private function parseNewAccessTokenFromResponse($body, $realmID = null){
        if(is_string($body)){
           $json_body = json_decode($body, true);
           if(json_last_error() === JSON_ERROR_NONE){
              $tokenExpiresTime = $json_body[CoreConstants::EXPIRES_IN];
              $refreshToken = $json_body[CoreConstants::OAUTH2_REFRESH_GRANTYPE];
              $refreshTokenExpiresTime = $json_body[CoreConstants::X_REFRESH_TOKEN_EXPIRES_IN];
              $accessToken = $json_body[CoreConstants::ACCESS_TOKEN];
              $this->checkIfEmptyValueReturned($tokenExpiresTime, $refreshToken, $refreshTokenExpiresTime, $accessToken);
              //If we have a response of OAuth 2 Access Token and the access token is not set, it must come from initial request. Create a dummy access token and update it.
              if(!isset($this->oauth2AccessToken)){
                  $this->oauth2AccessToken = new OAuth2AccessToken($this->getClientID(), $this->getClientSecret());
              }
              $this->oauth2AccessToken->updateAccessToken($tokenExpiresTime, $refreshToken, $refreshTokenExpiresTime, $accessToken);
              if(isset($realmID)){
                   $this->oauth2AccessToken->setRealmID($realmID);
              }
              return $this->oauth2AccessToken;
           }else{
              throw new SdkException("JSON DECODE encounters error:" . json_last_error());
           }
        }
    }
private function parseNewAccessTokenFromResponse($body, $realmID = null){
        if(is_string($body)){
           $json_body = json_decode($body, true);
           if(json_last_error() === JSON_ERROR_NONE){
              $tokenExpiresTime = $json_body[CoreConstants::EXPIRES_IN];
              $refreshToken = $json_body[CoreConstants::OAUTH2_REFRESH_GRANTYPE];
              $refreshTokenExpiresTime = $json_body[CoreConstants::X_REFRESH_TOKEN_EXPIRES_IN];
              $accessToken = $json_body[CoreConstants::ACCESS_TOKEN];
              $this->checkIfEmptyValueReturned($tokenExpiresTime, $refreshToken, $refreshTokenExpiresTime, $accessToken);
              //If we have a response of OAuth 2 Access Token and the access token is not set, it must come from initial request. Create a dummy access token and update it.
              if(!isset($this->oauth2AccessToken)){
                  $this->oauth2AccessToken = new OAuth2AccessToken($this->getClientID(), $this->getClientSecret());
              }
              $this->oauth2AccessToken->updateAccessToken($tokenExpiresTime, $refreshToken, $refreshTokenExpiresTime, $accessToken);
              if(isset($realmID)){
                   $this->oauth2AccessToken->setRealmID($realmID);
              }
              return $this->oauth2AccessToken;
           }else{
              throw new SdkException("JSON DECODE encounters error:" . json_last_error());
           }
        }
    }
private function parseNewAccessTokenFromResponse ( $ body , $ realmID = null ) { if ( is_string ( $ body ) ) { $ json_body = json_decode ( $ body , true ) ; if ( json_last_error ( ) === JSON_ERROR_NONE ) { $ tokenExpiresTime = $ json_body [ CoreConstants :: EXPIRES_IN ] ; $ refreshToken = $ json_body [ CoreConstants :: OAUTH2_REFRESH_GRANTYPE ] ; $ refreshTokenExpiresTime = $ json_body [ CoreConstants :: X_REFRESH_TOKEN_EXPIRES_IN ] ; $ accessToken = $ json_body [ CoreConstants :: ACCESS_TOKEN ] ; $ this -> checkIfEmptyValueReturned ( $ tokenExpiresTime , $ refreshToken , $ refreshTokenExpiresTime , $ accessToken ) ; //If we have a response of OAuth 2 Access Token and the access token is not set, it must come from initial request. Create a dummy access token and update it. if ( ! isset ( $ this -> oauth2AccessToken ) ) { $ this -> oauth2AccessToken = new OAuth2AccessToken ( $ this -> getClientID ( ) , $ this -> getClientSecret ( ) ) ; } $ this -> oauth2AccessToken -> updateAccessToken ( $ tokenExpiresTime , $ refreshToken , $ refreshTokenExpiresTime , $ accessToken ) ; if ( isset ( $ realmID ) ) { $ this -> oauth2AccessToken -> setRealmID ( $ realmID ) ; } return $ this -> oauth2AccessToken ; } else { throw new SdkException ( "JSON DECODE encounters error:" . json_last_error ( ) ) ; } } }
Parse the JSON Body to store the information to an OAuth 2 Access Token
@param String  $body       The JSON String contains all the OAuth 2 Access token information
@param String  $realmID    The realmID returned from authorization Code steps.It does not require for refresh token
Parse the JSON Body to store the information to an OAuth 2 Access Token