oauth-2.0 - 如何使用 instagram api 在没有 refresh_token 的情况下刷新 access_token
问题描述
我正在为我的 instagram 客户端刷新我的 access_token,这样我的用户就不需要在每次访问令牌过期时都登录。有没有办法在没有 refresh_token 的情况下做到这一点(instagram api 响应不包含 refresh_token)。
您可以在此处查看 instagram 列出的步骤:https ://www.instagram.com/developer/authentication/
这是 instagram oauth api 的响应对象:
{“access_token”:“fb2e77d.47a0479900504cb3ab4a1f626d174d2d”,“用户”:{“id”:“1574083”,“用户名”:“snoopdogg”,“full_name”:“Snoop Dogg”,“profile_picture”:“...” } }
我希望响应中有一个“refresh_token”字段,以便稍后我们可以请求一个新的“access_token”。
解决方案
First, you'll need to get a long-lived access token using the regular access token (which is only valid for one hour):
curl -i -X GET "https://graph.instagram.com/access_token
?grant_type=ig_exchange_token
&client_secret={instagram-app-secret}
&access_token={short-lived-access-token}"
Then, you can refresh the long-lived token by requesting the GET /refresh_access_token
endpoint using the long-lived token it-self:
curl -i -X GET "https://graph.instagram.com/refresh_access_token
?grant_type=ig_refresh_token
&access_token={long-lived-access-token}"
Refreshing a long-lived token makes it valid for 60 days again.
You can check the Instagram documentation for more details.
推荐阅读
- r - 从R中的数据框中拆分逗号分隔模式
- appium-android - 验证应用程序中的呼叫功能 - BDD - Appium
- azure-devops - 如何使用部署作业为 YAML Pipelines 构建仪表板
- python - 将带有 png 缩略图的数据框导出为 pdf python(已编辑 - 包含代码)
- python - 为什么保存的模型与训练模型的性能不同?
- python - 调用查询操作时发生发电机错误(ValidationException):KeyConditionExpression 无效:
- javascript - 无法读取 null 的属性(读取“动画”)错误 chrome JS 动画
- c# - 如何在 C# 中为字典中的现有键附加值
- c++ - 我如何告诉 clang-format 将 ContinuationIndentWidth 用于 lambda 参数?
- javascript - 回文索引 HackerRank JS