laravel-gmail icon indicating copy to clipboard operation
laravel-gmail copied to clipboard

refresh token and return new token to store it in database

Open hesham14yahia opened this issue 4 years ago • 1 comments

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 ??

hesham14yahia avatar Nov 10 '21 19:11 hesham14yahia

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.

ChrisSantiago82 avatar Dec 31 '21 13:12 ChrisSantiago82