访问口令

您可以通过此端点将短期Instagram 用户访问口令交换为长期 Instagram 用户访问口令。

创建

不支持此操作。

读取

GET /access_token

短期Instagram 用户访问口令交换为长期 Instagram 用户访问口令。

限制

由于请求长期口令时会包含应用密钥,因此该请求应只在服务器端代码中发出,而不能在可能被反编译的客户端代码或应用二进制文件中发出。请勿与任何人分享您的应用密钥、将其暴露在代码中、发送到客户端或是存储在设备上。

要求

请求语法

GET https://graph.instagram.com/access_token
  ?grant_type=ig_exchange_token
  &client_secret={instagram-app-secret}
  &access_token={short-lived-access-token}

查询字符串参数

添加以下查询字符串参数以扩充请求。

client_secret
必填
字符串

您的 Instagram 应用密钥会显示在应用面板 > 产品 > Instagram > 基本显示 > Instagram 应用密钥字段中。

grant_type
必填
字符串

将其设置为 ig_exchange_token

access_token
必填
字符串

您希望用其交换长期口令的有效(未过期)的短期 Instagram 用户访问口令。

响应

包含下列属性和值的 JSON 格式对象。

{ "access_token": "{access-token}", "token_type": "{token-type}", "expires_in": {expires-in} }

响应内容

值占位符

{access-token}
数字字符串

长期 Instagram 用户访问口令。

{token-type}
字符串

bearer

{expires-in}
整数

长期口令保持有效的秒数。

cURL 示例

请求

curl -X GET \ 'https://graph.instagram.com/access_token?grant_type=ig_exchange_token&&client_secret=eb87G...&access_token=IGQVJ...'

响应

{ "access_token": "lZAfb2dhVW...", "token_type": "bearer", "expires_in": 5183944 }

更新

不支持此操作。

删除

不支持此操作。