Hello,
I have two applications. One on the local network that syncs data with our Active Directory and one that is remote. I am syncing data between them using the API. The remote application is for emergency notification to our employees (power outages etc.)
As part of the syncing process when a new person is added to the local database it is added to the remote over the api. I am currently using passport and I set it up using php artisan passport:client –client
It is working but I think I am missing a step.
// This is athe testing server
$options = ['verify' => false];
$response = Http::withOptions($options)->asForm()->post(config('notify.url') .'/oauth/token', [
'grant_type' => 'client_credentials',
'client_id' => '1',
'client_secret' => 'ghdfghdfghdghdghghdtyertyetdfghdghd',
'scope' => '*',
]);
$token = $response->json()['access_token'];
$response = Http::withOptions($options)
->withToken($token)
->get(config('notify.url') . '/users');
The problem is each time I hit the config('notify.url') .'/oauth/token it adds a row to the oauth_access_token table. Each row has its own expires_at.
This seem to me that I need to visit 'oauth/token' and then stores the token. Then keep using that until it is used and the response from the remote application indicates it is expired - then hit the 'oauth/token' url again for a new token and then store that.
Is that how the work flow should go or am I missing something?