Hi I'm trying to get a token from an api but no matter what I try on the droplet I get an invalid client every single time, the code is the same locally and on the droplet, currently working on local but not on the droplet.
This is the code
return Cache::rememberForever('payment_token', function () {
$client = new Client(['http_errors' => false]);
$params = [
'client_id' => env('CLIENT_ID'),
'client_secret' => env('CLIENT_SECRET'),
'grant_type' => 'client_credentials',
];
$headers = [
'Accept' => 'application/json',
];
$response = $client->request('POST', 'https://apipay.io/auth/token/', [
'json' => $params,
'headers' => $headers
]);
$res_body = json_decode($response->getBody()->getContents());
return $res_body->access_token;
});
The url for the post isn't a real one, I don't really think it's wise to post the real one as it doesn't work without the client_id and client_secret which I can't post here.
Is there a reason why the droplet would interfere with this? What can I do to fix this?
Double-check the remote
.env
file and make sure, that it's not some outdated, cached version of it (whichenv()
would then return). Laravel has this feature, which can indeed be quite tricky, while not considering that (eg. it just doesn't work for no apparent reason).php artisan cache:clear
clears the config-cache andphp artisan config:cache
builds it up again; I even think that production uses a cached config by default (which may be the actual difference there).