Closed discoveryjames closed 4 years ago
Ah yes that makes sense,
The tokens from Xero only live for 30 minutes before they must be renewed and we only check if they're expired when the credential manager is first resolved since the standard usecase is web requests that last only a few seconds.
The configuration object for Xero is a singleton (not using Laravel's DI container),
So you should be able to do the following regularly in your job to refresh the token. I would suggest doing it no more than every 15 minutes though.
$credentials = $app->make(OauthCredentialManager::class);
$config = Configuration::getDefaultConfiguration();
$credentials->refresh();
$config->setAccessToken($credentials->getAccessToken());
Hi,
I've noticed when running console jobs which run for over 30 minutes - the token expires so all activity halts until the console job is ran again.
Is there a safe way to manually get a new token?