Merge pull request #5993 from turbo124/v5-develop

Gmail offline_access
This commit is contained in:
David Bomba 2021-06-10 17:17:15 +10:00 committed by GitHub
commit 0883e62c73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -491,23 +491,23 @@ class LoginController extends BaseController
{ {
//'https://www.googleapis.com/auth/gmail.send','email','profile','openid' //'https://www.googleapis.com/auth/gmail.send','email','profile','openid'
$scopes = []; $scopes = [];
$parameters = [];
if($provider == 'google'){ if($provider == 'google'){
$scopes = ['gmail.send','email','profile','openid']; $scopes = ['https://www.googleapis.com/auth/gmail.send','email','profile','openid'];
$parameters = ['access_type' => 'offline', 'redirect_uri' => config('ninja.app_url')."/auth/google"];
} }
if (request()->has('code')) { if (request()->has('code')) {
return $this->handleProviderCallback($provider); return $this->handleProviderCallback($provider);
} else { } else {
return Socialite::driver($provider)->with(['redirect_uri' => config('ninja.app_url')."/auth/google"])->scopes($scopes)->redirect(); return Socialite::driver($provider)->with($parameters)->scopes($scopes)->redirect();
} }
} }
public function handleProviderCallback(string $provider) public function handleProviderCallback(string $provider)
{ {
$socialite_user = Socialite::driver($provider) $socialite_user = Socialite::driver($provider)->user();
->with(['redirect_uri' => config('ninja.app_url')."/auth/google"])
->user();
if($user = OAuth::handleAuth($socialite_user, $provider)) if($user = OAuth::handleAuth($socialite_user, $provider))
{ {