google-calendar-api - 获取刷新 token 谷歌API

标签 google-calendar-api token access-token gdata

我无法使用我的代码获取刷新 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_tokentoken_typeid_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/

相关文章:

google-calendar-api - Google Calendar API - 如何添加日历小工具和事件?

javascript - 如何保护仅从前端使用的 API(Ajax 调用)

azure - 如何在脚本中使用 system.accesstoken 创建 Azure Devops 服务连接

google-calendar-api - Google Calendar API : Editing a single occurrence of a recurring event

python - 在 GAE(日历 API)的 Python 中解析来自 InsertCalendar 的原子响应

ios - 使用服务帐户访问 IOS 中的 Google 日历

javascript - 为多个客户端渲染 html View

ios - 如何在 swift 的 Alamofire Post 请求中将 token 字符串(jwt)作为 Cookie 发送?

Facebook 访问 token 已过期

spring - Spring OAuth2 中的/check_token 和 user-info-uri 端点有什么区别?