src/Api/Client.php
public function fetchAccessToken($redirect_code)
    {
        $http = $this->getHTTPClient();
        $post_data = [
            'client_id' => $this->client_id,
            'client_secret' => $this->client_secret,
            'grant_type' => 'authorization_code',
            'code' => $redirect_code,
            'redirect_uri' => $this->getRedirectURL(),
        ];
        // Request access token
        try {
            $response = $http->request('POST', 'oauth/access_token', [
                'form_params' => $post_data
            ]);

            $responseBody = $response->getBody();
            $responseArr = json_decode($responseBody, true);

            //Set new data into the config and update the current instance
            $this->setAccessToken($responseArr['access_token']);
            $this->setAccessTokenExpire($responseArr['expires_in']);
            $this->setRefreshToken($responseArr['refresh_token']);
        } catch (\Exception  $exception) {
            $this->handleException($exception);
        }
    }
public function fetchAccessToken($redirect_code)
    {
        $http = $this->getHTTPClient();
        $post_data = [
            'client_id' => $this->client_id,
            'client_secret' => $this->client_secret,
            'grant_type' => 'authorization_code',
            'code' => $redirect_code,
            'redirect_uri' => $this->getRedirectURL(),
        ];
        // Request access token
        try {
            $response = $http->request('POST', 'oauth/access_token', [
                'form_params' => $post_data
            ]);

            $responseBody = $response->getBody();
            $responseArr = json_decode($responseBody, true);

            //Set new data into the config and update the current instance
            $this->setAccessToken($responseArr['access_token']);
            $this->setAccessTokenExpire($responseArr['expires_in']);
            $this->setRefreshToken($responseArr['refresh_token']);
        } catch (\Exception  $exception) {
            $this->handleException($exception);
        }
    }
public function fetchAccessToken ( $ redirect_code ) { $ http = $ this -> getHTTPClient ( ) ; $ post_data = [ 'client_id' => $ this -> client_id , 'client_secret' => $ this -> client_secret , 'grant_type' => 'authorization_code' , 'code' => $ redirect_code , 'redirect_uri' => $ this -> getRedirectURL ( ) , ] ; // Request access token
 try { $ response = $ http -> request ( 'POST' , 'oauth/access_token' , [ 'form_params' => $ post_data ] ) ; $ responseBody = $ response -> getBody ( ) ; $ responseArr = json_decode ( $ responseBody , true ) ; //Set new data into the config and update the current instance
 $ this -> setAccessToken ( $ responseArr [ 'access_token' ] ) ; $ this -> setAccessTokenExpire ( $ responseArr [ 'expires_in' ] ) ; $ this -> setRefreshToken ( $ responseArr [ 'refresh_token' ] ) ; } catch ( \ Exception $ exception ) { $ this -> handleException ( $ exception ) ; } }
Fetch OAuth Access token from the HAil API

@param string $redirect_code

@throws
Fetch OAuth Access token from the HAil API