问题
I'm being redirected to the Google Consent for the first time and asked if I allow this application to manage Gmail account and stuff. And when I'm redirected back, refresh token is null.
+token:"ya29.Gls1BTQIRIuCW2dnzIpQlciOZNpidhjfsoidjfsomethingsm"
+refreshToken: null
+expiresIn: 3600
I know Refresh Token comes null on subsequent requests. But this was the first request I made.
Is there something I need to do on the console side.
回答1:
Solved it. I forgot to set access_type
to offline
$client->setAccessType('offline');
In my case I was using Larave/Socialite
Socialite::driver('google')->with(['access_type'=>'offline'])->redirect();
Ref: https://developers.google.com/identity/protocols/OAuth2WebServer
来源:https://stackoverflow.com/questions/48049969/not-receiving-refresh-token-even-in-the-first-consent-google-api