我已经按照指南 Google login / Expo并获得了访问 token 和刷新 token 。
但是在访问 token 到期后,我无法获得新的 token 。
当我尝试获取新的时,我收到此错误:"error": "unauthorized_client", "error_description": "Unauthorized"
以下是获取新访问 token (Google docs) 的已发送请求示例:
POST /oauth2/v4/token HTTP/1.1
Host: www.googleapis.com
Content-Type: application/x-www-form-urlencoded
client_id=<your_client_id>&
client_secret=<your_client_secret>&
refresh_token=<refresh_token>&
grant_type=refresh_token
附言我没有忘记替换 client_id 和其他相关数据。
最佳答案
必须使用获得刷新 token 的同一客户端 ID 来获得另一个访问 token !
您可能在 Android 上使用此代码,对于移动设备,Google 不会给您任何 secret ,因为它不是必需的。您可以从请求中删除 key 并更改客户端 ID 以匹配您的移动客户端 ID。
关于javascript - 使用 Expo SDK 刷新 Google API 访问 token ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49780746/