angular - 如何从grantOfflineAccess返回的response_code中获取refresh_token
问题描述
我对 invalid_grant 问题感到震惊。我参考了 gapi doc 并像这样实现流程,
var authorisationRequestData =
{
'client_id': clientId,
'scope': scopes,
'immediate': immediate,
prompt: 'consent',
access_type: 'offline',
include_granted_scope: true,
}
const authInstance = gapi.auth2.getAuthInstance();
authInstance.grantOfflineAccess(authorisationRequestData)
.then((res) => {
console.log(gapi.auth.getToken());
var all_token = JSON.stringify(gapi.auth.getToken());
console.log("Token =" + all_token);
console.log(res);
console.log(res.code);
}).catch(error => {
console.log(error);
});
我从上面的实现中获得了访问令牌和 response_code,并且能够针对用户创建日历事件。但是 1 小时后它给了我错误,例如“错误:invalid_grant,代码:400”。grantOfflineAccess 的令牌返回,例如“4/-QA8fj7FyvcPzlVwsapQwyqyKJs0MwkQlNdGhACVgOx3YSP5JamyEplViIx-uSV3JeAHrp9n0RZC0FMSX7IwAQk”
解决方案
推荐阅读
- python-3.x - python repr函数在调用时不使用引号
- java - 有没有办法在控制器类之外访问 Spring 控制器参数?
- c++ - 如何使用递归打印最长公共子序列中涉及的字符串?
- c# - 无法加载类型“NewSite.MvcApplication”kentico
- javascript - 从文本框中删除文本
- rust - 为什么 `Regex::new` 的结果不能分配给常量?
- python - 如何将“0 天 00:09:06.633000000”对象转换为分钟/小时/秒?
- javascript - Angular 8 在异步调用链后返回 observable
- c++ - 模板化运算符重载不能绑定非常量左值引用
- python - 如果两列跨 DF 匹配,我如何将两个 DF 与 python 合并