ruby-on-rails - 使用 Google OAuth 2 API 刷新令牌时如何修复“帐户已被删除”
问题描述
最近,由于某种未知原因,我们的谷歌分析 API 无法正常运行。我知道这个问题围绕着一些帐户删除。例如,这里是刷新访问令牌的代码:
uri = URI.parse('https://www.googleapis.com/oauth2/v4/token')
params = {
client_id: client_id,
client_secret: client_secret,
refresh_token: token,
grant_type: 'refresh_token'
}
headers = {
'Content-Type' => 'application/x-www-form-urlencoded'
}
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
post_request = Net::HTTP::Post.new(uri.path, headers)
query = URI.encode_www_form(params)
post_request.body = query
response = http.request(post_request)
响应返回此:
#<Net::HTTPBadRequest 400 Bad Request readbody=true>
response.body = "{\n \"error\": \"invalid_grant\",\n \"error_description\": \"Account has been deleted\"\n}"
我花了很长时间弄清楚如何解决这个问题。我需要重新创建什么帐户?服务帐户?文档真的不清楚。
解决方案
推荐阅读
- css - React Native 角样式 FlatList 组件
- postgresql - 当我恢复我的数据时,我使用 pg_restore 但它给了我错误我尝试了所有解决方案
- priority-web-sdk - webSdk 过程的参数顺序
- playframework - 如何将 Source[String, Future[IOResult]] 转换为 Source[ByteString, Future[IOResult]]
- python - Django React Python Post 请求图像分类
- azure - IaC Azure 自动化
- spacy - 如何使用 Spacy Matcher 松散匹配单词之间的异常
- c# - Blazor 中的程序元素引用
- git - 默认使用 git remote --verbose
- python - 将 Pandas 数据框写入雪花但日期列出现问题