获取授权小程序接口调用凭据
接口介绍
该接口用于获取授权小程序接口调用凭据。授权小程序接口调用凭据 authorizer_access_token 是服务商代授权小程序调用开放接口的必要条件。
注意:
- •authorizer_access_token 有效期 2 小时。
请求
基本信息
| 基本 |  | 
| HTTP URL | |
| HTTP Method | GET | 
查询参数
| 参数名 | 参数类型 | 是否必须 | 备注 | 
| component_appid | string | 是 | 第三方小程序应用 appid | 
| component_access_token | string | 是 | 第三方小程序应用接口调用凭据 | 
| authorization_code | string | 是 | 授权码 | 
| grant_type | string | 是 | 固定字符串:app_to_tp_authorization_code | 
响应
响应体
| 参数名 | 参数类型 | 是否必须 | 备注 | |
| authorizer_access_token | string | 是 | 授权小程序接口调用凭据 | |
| expires_in | int | 是 | authorizer_access_token 的有效期,单位:秒 | |
| authorizer_refresh_token | string | 是 | 刷新令牌,用于刷新已授权小程序的 authorizer_access_token | |
| refresh_expires_in | int | 是 | authorizer_refresh_token 的有效期,单位:秒 | |
| authorizer_appid | string | 是 | 授权小程序 appid | |
| authorize_permission | Array<object> | 是 | 授权小程序在授权跳转页勾选的权限 | |
|  | id | int | 是 | 权限id | 
|  | category | string | 是 | 权限名称 | 
|  | description | string | 是 | 权限描述 | 
目前小程序可授予的权限有:
[ { id: 1, category: "开发管理权限", description: "帮助小程序进行基础功能开发及配置开发所需信息", }, { id: 2, category: "基本信息设置权限", description: "帮助小程序管理名称、头像、简介、服务类目等信息", }, { id: 3, category: "运营管理权限", description: "帮助小程序接入平台提供的开放能力,包括自主挂载、达人推广、搜索等", }, { id: 4, category: "数据分析权限", description: "能够获得小程序相关数据并进行数据分析,主要包括小程序用户数据及交易数据", }, { id: 5, category: "广告管理权限", description: "帮助小程序进行广告投放及管理", }, { id: 6, category: "支付服务权限", description: "帮助小程序开通及使用支付产品,并获得支付产生的相关数据", }, { id: 7, category: "流量主权限", description: "帮助开发者管理小程序内的广告变现业务", }, { id: 8, category: "小程序推广计划-任务管理权限", description: "帮助开发者发布小程序推广任务并查看任务相关信息", }, ];
响应体示例
{ "authorizer_access_token": "08021218466f6f2b4d672f3658783566365448746a7a325679513d3d", "expires_in": 7200, "authorizer_refresh_token": "0740283fdbbc11174807dfcbe9b6b566bc5e7542305b1f0d9cb958eba030488cd1acb22d68a97099843629c77ea21a5cee021a08021218466f6f2b4d672f3658783566365448746a7a3256795133", "refresh_expires_in": 2592000, "authorizer_appid": "xxx", "authorize_permission": [ { "id": 1, "category": "开发管理权限", "description": "帮助小程序进行功能开发和开发设置" }, ...... ] }
注意:
- •authorizer_refresh_token 有效期 1 个月,且只可使用一次,使用后失效。
错误码
| 错误码 | message | 
| 40001 | 参数错误 | 
| 40002 | 缺少参数 | 
| 40003 | 找不到相关第三方小程序应用 | 
| 40004 | 找不到相关授权小程序 | 
| 40009 | 第三方小程序应用 component_access_token 已过期 | 
| 40010 | 第三方小程序应用 component_access_token 不正确 | 
| 40018 | 第三方小程序应用 authorization_code 不正确或者已过期 | 
| 40040 | 无效的 grant_type | 
| 40045 | 生成 token 失败,请重试 | 
