默认情况下,Threads 用户访问口令是短期访问口令,仅在 1 小时内有效。但短期口令可以交换为长期口令。
长期口令的有效期是 60 天,只要至少已存在 24 小时但尚未过期,且应用用户已授予应用 threads_basic 权限,就可以刷新长期口令。已刷新口令的有效期为:自刷新之日起 60 天。60 天内未经刷新的口令将会过期,已过期的口令将不能再刷新。
现在可以刷新 Threads 私密主页的长期访问口令。另外,拥有私密主页的应用用户授予应用的权限的有效期现为 90 天。
使用 GET /access_token 端点将 Threads 短期用户访问口令交换为长期口令。获取长期口令后,您可以在服务器端请求中使用或将其发送回客户端使用。
您必须在服务器端发起请求,其中应包括:
添加以下查询字符串参数以扩展请求。
| 名称 | 描述 |
|---|---|
字符串
| 必要。 |
字符串
| 必要。 |
字符串
| 必要。 |
curl -i -X GET "https://graph.threads.net/access_token ?grant_type=th_exchange_token &client_secret=<THREADS_APP_SECRET> &access_token=<SHORT_LIVED_ACCESS_TOKEN>"
{
"access_token": "<LONG_LIVED_USER_ACCESS_TOKEN>",
"token_type": "bearer",
"expires_in": 5183944 // number of seconds until token expires
}
使用 GET /refresh_access_token 端点刷新未过期的 Threads 长期用户访问口令。刷新长期口令后,口令可再次获得 60 天的有效期。60 天内未经刷新的长期口令将会过期。
请求中必须包含:
| 名称 | 描述 |
|---|---|
字符串
| 必要。 |
字符串
| 必要。 |
curl -i -X GET "https://graph.threads.net/refresh_access_token ?grant_type=th_refresh_token &access_token=<LONG_LIVED_ACCESS_TOKEN>"
{
"access_token": "<LONG_LIVED_USER_ACCESS_TOKEN>",
"token_type": "bearer",
"expires_in": 5183944 // number of seconds until token expires
}