laravel-gmail
laravel-gmail copied to clipboard
refresh token and return new token to store it in database
I'm sending a scheduled email by a cronjob in the background so I take the callback
$callback = LaravelGmail::makeToken();
and save it and use it when the email schedule comes, the issue I'm having is that there isn't a way to refresh the token and get a new one when the access token expires, is there is a method to give it refresh_token and return for me fresh access_token ??
I have done something like this:
if (LaravelGmail::setUserId('ea_'.$this->emailAccount->id)->isAccessTokenExpired()) { LaravelGmail::setUserId('ea_'.$this->emailAccount->id)->refreshToken(LaravelGmail::setUserId('ea_'.$this->emailAccount->id)->getRefreshToken()); } LaravelGmail::setUserId('ea_'.$this->emailAccount->id)->makeToken();
It seems to work but not sure if that is the way it should be.