src/API.php
private function getAuthHeaders($email, $password, $clientConfig)
    {
        if (!$email || !$password) {
            return [];
        }

        if (!isset($clientConfig['oauth2']['enabled']) || !$clientConfig['oauth2']['enabled']) {
            return [
                'X-API-Email-Enc'    => base64_encode($email),
                'X-API-Password-Enc' => base64_encode($password),
                'X-API-Email'        => $email,
                'X-API-Password'     => $password
            ];
        }

        $oauth2Config = $clientConfig['oauth2'];
        $accessToken = array_key_exists('access_token', $oauth2Config) ? $oauth2Config["access_token"] : "";
        if (empty($accessToken)) {
            $accessToken = $this->getAccessToken($email, $password, $clientConfig);
        }

        if (!$accessToken) {
            throw new Exception('Cannot find/create valid token');
        }

        return [
            'Authorization' => "Bearer {$accessToken}"
        ];
    }
private function getAuthHeaders($email, $password, $clientConfig)
    {
        if (!$email || !$password) {
            return [];
        }

        if (!isset($clientConfig['oauth2']['enabled']) || !$clientConfig['oauth2']['enabled']) {
            return [
                'X-API-Email-Enc'    => base64_encode($email),
                'X-API-Password-Enc' => base64_encode($password),
                'X-API-Email'        => $email,
                'X-API-Password'     => $password
            ];
        }

        $oauth2Config = $clientConfig['oauth2'];
        $accessToken = array_key_exists('access_token', $oauth2Config) ? $oauth2Config["access_token"] : "";
        if (empty($accessToken)) {
            $accessToken = $this->getAccessToken($email, $password, $clientConfig);
        }

        if (!$accessToken) {
            throw new Exception('Cannot find/create valid token');
        }

        return [
            'Authorization' => "Bearer {$accessToken}"
        ];
    }
private function getAuthHeaders ( $ email , $ password , $ clientConfig ) { if ( ! $ email || ! $ password ) { return [ ] ; } if ( ! isset ( $ clientConfig [ 'oauth2' ] [ 'enabled' ] ) || ! $ clientConfig [ 'oauth2' ] [ 'enabled' ] ) { return [ 'X-API-Email-Enc' => base64_encode ( $ email ) , 'X-API-Password-Enc' => base64_encode ( $ password ) , 'X-API-Email' => $ email , 'X-API-Password' => $ password ] ; } $ oauth2Config = $ clientConfig [ 'oauth2' ] ; $ accessToken = array_key_exists ( 'access_token' , $ oauth2Config ) ? $ oauth2Config [ "access_token" ] : "" ; if ( empty ( $ accessToken ) ) { $ accessToken = $ this -> getAccessToken ( $ email , $ password , $ clientConfig ) ; } if ( ! $ accessToken ) { throw new Exception ( 'Cannot find/create valid token' ) ; } return [ 'Authorization' => "Bearer {$accessToken}" ] ; }
Get the authentication headers

@param string $email
@param string $password
@param array $clientConfig
@return array
@throws Exception
Get the authentication headers