shop-back-end/doc/simpread-获取企业永久授权码 - 文档 - 企...

118 lines
9.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

> 本文由 [简悦 SimpRead](http://ksria.com/simpread/) 转码, 原文地址 [developer.work.weixin.qq.com](https://developer.work.weixin.qq.com/document/14942) 获取企业永久授权码 最后更新2024/07/12
该 API 用于使用临时授权码换取授权方的永久授权码,并换取授权信息、企业 access_token临时授权码一次有效。
**请求方式:**POST**HTTPS**
**请求地址:** https://qyapi.weixin.qq.com/cgi-bin/service/get_permanent_code?suite_access_token=SUITE_ACCESS_TOKEN
**请求包体:**
```
{
"auth_code": "auth_code_value"
}
```
**参数说明:**
<table><thead><tr><th>参数</th><th>是否必须</th><th>说明</th></tr></thead><tbody><tr><td>auth_code</td><td></td><td><a href="#10974" rel="nofollow">临时授权码</a>,会在授权成功时附加在 redirect_uri 中跳转回第三方服务商网站,或通过<a href="#14951" rel="nofollow">授权成功通知</a>回调推送给服务商。长度为 64 至 512 个字节</td></tr></tbody></table>
**返回结果:**
```
{
"errcode":0,
"errmsg":"ok",
"access_token": "xxxxxx",
"expires_in": 7200,
"permanent_code": "xxxx",
"dealer_corp_info":
{
"corpid": "xxxx",
"corp_name": "name"
},
"auth_corp_info":
{
"corpid": "xxxx",
"corp_name": "name",
"corp_type": "verified",
"corp_square_logo_url": "yyyyy",
"corp_user_max": 50,
"corp_full_name":"full_name",
"verified_end_time":1431775834,
"subject_type": 1,
"corp_wxqrcode": "zzzzz",
"corp_scale": "1-50人",
"corp_industry": "IT服务",
"corp_sub_industry": "计算机软件/硬件/信息服务"
},
"auth_info":
{
"agent" :
[
{
"agentid":1,
"name":"NAME",
"round_logo_url":"xxxxxx",
"square_logo_url":"yyyyyy",
"appid":1,
"auth_mode":1,
"is_customized_app":false,
"auth_from_thirdapp":false,
"privilege":
{
"level":1,
"allow_party":[1,2,3],
"allow_user":["zhansan","lisi"],
"allow_tag":[1,2,3],
"extra_party":[4,5,6],
"extra_user":["wangwu"],
"extra_tag":[4,5,6]
},
"shared_from":
{
"corpid":"wwyyyyy",
"share_type": 1
}
},
{
"agentid":2,
"name":"NAME2",
"round_logo_url":"xxxxxx",
"square_logo_url":"yyyyyy",
"appid":5,
"shared_from":
{
"corpid":"wwyyyyy",
"share_type": 0
}
}
]
},
"auth_user_info":
{
"userid":"aa",
"open_userid":"xxxxxx",
"name":"xxx",
"avatar":"http://xxx"
},
"register_code_info":
{
"register_code":"1111",
"template_id":"tpl111",
"state":"state001"
},
"state":"state001"
}
```
**参数说明:**
<table><thead><tr><th>参数</th><th>说明</th></tr></thead><tbody><tr><td>access_token</td><td>授权方企业access_token, 最长为 512 字节。代开发自建应用安装时不返回。</td></tr><tr><td>expires_in</td><td>授权方企业access_token 超时时间(秒)。代开发自建应用安装时不返回。</td></tr><tr><td>permanent_code</td><td>企业微信永久授权码, 最长为 512 字节</td></tr><tr><td>auth_corp_info</td><td>授权方企业信息</td></tr><tr><td>auth_corp_info.corpid</td><td>授权方企业微信 id</td></tr><tr><td>auth_corp_info.corp_name</td><td>授权方企业名称,即企业简称</td></tr><tr><td>auth_corp_info.corp_type</td><td>授权方企业类型认证号verified, 注册号unverified</td></tr><tr><td>auth_corp_info.corp_square_logo_url</td><td>授权方企业方形头像</td></tr><tr><td>auth_corp_info.corp_user_max</td><td>授权方企业用户规模</td></tr><tr><td>auth_corp_info.corp_full_name</td><td>授权方企业的主体名称 (仅<a href="https://work.weixin.qq.com/help?person_id=1&amp;doc_id=17288" rel="nofollow">认证或验证</a>过的企业有),即企业全称。企业微信将逐步回收该字段,后续实际返回内容为企业名称,即 auth_corp_info.corp_name。</td></tr><tr><td>auth_corp_info.subject_type</td><td>企业类型1. 企业; 2. 政府以及事业单位; 3. 其他组织, 4. 团队号</td></tr><tr><td>auth_corp_info.verified_end_time</td><td>认证到期时间</td></tr><tr><td>auth_corp_info.corp_wxqrcode</td><td>授权企业在微信插件(原企业号)的二维码,可用于关注微信插件</td></tr><tr><td>auth_corp_info.corp_scale</td><td>企业规模。当企业未设置该属性时,值为空。<a href="#30245" rel="nofollow">成员授权</a>下,即 auth_info.agent.auth_mode 为 1 时值为空</td></tr><tr><td>auth_corp_info.corp_industry</td><td>企业所属行业。当企业未设置该属性时,值为空。<a href="#30245" rel="nofollow">成员授权</a>下,即 auth_info.agent.auth_mode 为 1 时值为空</td></tr><tr><td>auth_corp_info.corp_sub_industry</td><td>企业所属子行业。当企业未设置该属性时,值为空。<a href="#30245" rel="nofollow">成员授权</a>下,即 auth_info.agent.auth_mode 为 1 时值为空</td></tr><tr><td>auth_info</td><td>授权信息。如果是通讯录应用,且没开启实体应用,是没有该项的。通讯录应用拥有企业通讯录的全部信息读写权限。「第三方会话存档接口」不返回该字段</td></tr><tr><td>auth_info.agent</td><td>授权的应用信息,注意是一个数组,但仅旧的多应用套件授权时会返回多个 agent对新的单应用授权永远只返回一个 agent</td></tr><tr><td>auth_info.agent.agentid</td><td>授权方应用 id</td></tr><tr><td>auth_info.agent.name</td><td>授权方应用名字</td></tr><tr><td>auth_info.agent.square_logo_url</td><td>授权方应用方形头像</td></tr><tr><td>auth_info.agent.round_logo_url</td><td>授权方应用圆形头像</td></tr><tr><td>auth_info.agent.appid</td><td>旧的多应用套件中的对应应用 id新开发者请忽略</td></tr><tr><td>auth_info.agent.auth_mode</td><td>授权模式0 为管理员授权1 为<a href="#30245" rel="nofollow">成员授权</a></td></tr><tr><td>auth_info.agent.is_customized_app</td><td>是否为代开发自建应用</td></tr><tr><td>auth_info.agent.auth_from_thirdapp</td><td>来自第三方应用接口唤起, 仅通过<a href="#37304" rel="nofollow">第三方应用添加自建应用</a> 获取授权链接授权代开发自建应用时,才返回该字段</td></tr><tr><td>auth_info.agent.privilege</td><td>应用对应的权限</td></tr><tr><td>auth_info.agent.privilege.allow_party</td><td>应用可见范围(部门)</td></tr><tr><td>auth_info.agent.privilege.allow_tag</td><td>应用可见范围(标签)</td></tr><tr><td>auth_info.agent.privilege.allow_user</td><td>应用可见范围(成员)</td></tr><tr><td>auth_info.agent.privilege.extra_party</td><td>额外通讯录(部门)</td></tr><tr><td>auth_info.agent.privilege.extra_user</td><td>额外通讯录(成员)</td></tr><tr><td>auth_info.agent.privilege.extra_tag</td><td>额外通讯录(标签)</td></tr><tr><td>auth_info.agent.privilege.level</td><td>权限等级。<br>1: 通讯录基本信息只读<br>2: 通讯录全部信息只读<br>3: 通讯录全部信息读写<br>4: 单个基本信息只读<br>5: 通讯录全部信息只写</td></tr><tr><td>auth_info.agent.shared_from</td><td>共享了应用的企业信息,仅当由<a href="#24909" rel="nofollow">企业互联</a>或者<a href="#35931" rel="nofollow">上下游</a>共享应用触发的安装时才返回</td></tr><tr><td>auth_info.agent.shared_from.corpid</td><td>共享了应用的企业信息,仅当<a href="#24909" rel="nofollow">企业互联</a>或者<a href="#35931" rel="nofollow">上下游</a>共享应用触发的安装时才返回</td></tr><tr><td>auth_info.agent.shared_from.share_type</td><td>共享了途径0 表示企业互联1 表示上下游</td></tr><tr><td>auth_user_info</td><td>授权管理员的信息,可能不返回</td></tr><tr><td>auth_user_info.userid</td><td>授权管理员的 userid可能为空</td></tr><tr><td>auth_user_info.open_userid</td><td>授权管理员的 open_userid可能为空</td></tr><tr><td>auth_user_info.name</td><td>授权管理员的 name可能为空</td></tr><tr><td>auth_user_info.avatar</td><td>授权管理员的头像 url可能为空</td></tr><tr><td>dealer_corp_info</td><td><a href="#15259" rel="nofollow">代理服务商</a>企业信息。应用被代理后才有该信息</td></tr><tr><td>dealer_corp_info.corpid</td><td><a href="#15259" rel="nofollow">代理服务商</a>企业微信 id</td></tr><tr><td>dealer_corp_info.corp_name</td><td><a href="#15259" rel="nofollow">代理服务商</a>企业微信名称</td></tr><tr><td>register_code_info</td><td>推广二维码安装相关信息,扫推广二维码安装时返回。成员授权时暂不支持。(注:无论企业是否新注册,只要通过扫推广二维码安装,都会返回该字段)</td></tr><tr><td>register_code_info.register_code</td><td>注册码</td></tr><tr><td>register_code_info.template_id</td><td>推广包 ID</td></tr><tr><td>register_code_info.state</td><td>仅当<a href="#14934" rel="nofollow">获取注册码</a>指定该字段时才返回</td></tr><tr><td>state</td><td>安装应用时,扫码或者授权链接中带的 state 值。详见 state 说明</td></tr></tbody></table>
**注意**:因历史原因,该接口在调用失败时才返回 errcode。没返回 errcode 视为调用成功
**state 说明:**
目前会返回 state 包含以下几个场景。
1扫带参二维码授权代开发模版。