Closed FiveX-dev closed 4 years ago
We get this too. If I use a clientpool then the details of the last client are used. It looks likes the logon details are cached somwhere.
I tried before without the clientpool, if I restart the script the details of the last call are used. Somehow the connection has to be terminated or cleared.
With regards, Theo
The reason why this issue is occurring, is because multiple clients will share the same access token path. Simply giving the clients another path in the ClientConfig constructor solved the problem for us.
I understand the idea, but how to implement this?
As stated in the README.md file in the “Multiple account support” section, you can create a client pool using multiple clients. These clients take a ClientConfig class to be instantiated. The constructor of the ClientConfig currently takes 5 parameters.
public function __construct(string $clientId, string $clientSecret, bool $testMode = false, string $accessTokenPath = '/tmp/bol_access_token.json', bool $enabled = true)
You can change the access token path by overriding the default value. (e.g. ‘/tmp/bol_access_token_1.json’ for your first account)
I changed the following in ClientConfig.php:
public function __construct( .... $this->accessTokenPath = $accessTokenPath;
Change to: $this->accessTokenPath = $accessTokenPath.$clientId.'.json';
To make it a different token json for each clientid. add the client id. Don't think this should be a security risq
You do not want to change the source files. Changing the access token path can be done in your own code.
$clientPool = new \BolCom\RetailerApi\Infrastructure\ClientPool([
'account1' => new \BolCom\RetailerApi\Client(new \BolCom\RetailerApi\Client\ClientConfig('clientId1', 'clientSecret1', $testMode = false, $accessTokenPath = ‘/tmp/bol_access_token_1.json’)),
]);
This doesn't work. The filename is not changed, ti defaults to the standard.
When I run the following code it returns the inventory response of the first user in the clientPool for all users...