not receiving “Refresh Token” even in the first consent - Google API

落花浮王杯 提交于 2020-01-24 01:37:28

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!