我无法使用我的代码获取刷新 token 。我只能获取我的访问 token 、 token 类型等,
我遵循了一些教程,例如将 access_type=offline
放在我的登录 URL 上:
echo "<a href='https://accounts.google.com/o/oauth2/auth?"
. "access_type=offline&client_id=123345555.apps.googleusercontent.com& "
. "scope=https://www.googleapis.com/auth/calendar+https://www.googleapis.com/auth/plus.me&response_type=code& "
. "redirect_uri=http://www.sample.com/sample.php&state=/profile'>Google</a>";
以及我获取访问 token 的字段:
$fields=array(
'code'=> urlencode($authcode),
'client_id'=> urlencode($clientid),
'client_secret'=> urlencode($clientsecret),
'redirect_uri'=> urlencode($redirecturi),
'grant_type'=> 'authorization_code',
);
但我无法获取refresh_token,只有access_token、token_type、id_token和过期时间。
最佳答案
通过将其添加到您的网址参数中找到
approval_prompt=force
更新:
改用access_type=offline&prompt=consent
。
approval_prompt=force
不再有效
https://github.com/googleapis/oauth2client/issues/453
关于google-calendar-api - 获取刷新 token 谷歌API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8942340/