续订长期访问令牌服务器端 [英] Renew long lived access token server side

查看:143
本文介绍了续订长期访问令牌服务器端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在从Facebook中检索长期访问令牌,但是我们需要自动更新此令牌,以便每60天不会过期。

We are retrieving the long lived access token from facebook fine, however we need to renew this token automatically so that it does not expire every 60 days.

阅读文档说,您只能使用端点交换短命令令牌。

Reading the documentation it says you can only exchange short lived tokens using the endpoint.

由于我们没有短命令令牌,我们如何做这个服务器端,而不必每60天手动重新授权一次?

As we don't have the short lived token, how can we do this server-side without having to manually re-authorize every 60 days?

推荐答案

不可能不断地扩展令牌。请参阅这里的方案4 https://developers.facebook.com/roadmap/offline-access-删除/

it is not possible, to extend token endlessly. See Scenario 4 here https://developers.facebook.com/roadmap/offline-access-removal/:


使用下面的新端点,您将可以扩展
到期时间现有的,未过期的,短命的用户
access_token。请注意,端点只能用于延长
短期用户access_tokens
。如果你传递一个access_token
有一个长期的到期时间,端点将简单地传递
相同的access_token回到你,而不改变或扩展
到期时间。

Using the new endpoint below, you will be able to extend the expiration time of an existing, non-expired, short-lived user access_token. Please note, the endpoint can only be used to extend the short-lived user access_tokens. If you pass an access_token that had a long-lived expiration time, the endpoint will simply pass that same access_token back to you without altering or extending the expiration time.

为了让长期存在的用户access_token只需将您自己的client_id
(您的app_id),您的app_secret和未过期的短期
access_token传递给下面的端点。您将返回一个新的
长寿命的用户access_token;这个access_token将另外存在传递到端点的短命令access_token

如果您想刷新一个仍然有效的长寿命的access_token,则必须先获取一个新的短期用户access_token,然后
调用下面的同一个端点。返回的access_token将具有
a新鲜长寿的到期时间,但是access_token本身的
可能与以前授予的长寿命
access_token相同。

To get the long-lived user access_token simply pass your own client_id (your app_id), your app_secret, and the non-expired, short-lived access_token to the endpoint below. You will be returned a new long-lived user access_token; this access_token will exist in addition to the short-lived access_token that was passed into the endpoint. If you would like to refresh a still valid long-lived access_token, you will have to get a new short-lived user access_token first and then call the same endpoint below. The returned access_token will have a fresh long-lived expiration time, however, the access_token itself may or may not be the same as the previously granted long-lived access_token.

这篇关于续订长期访问令牌服务器端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆