# 与钉钉集成

## Content

## 1\. 概述

### 1.1 功能概述

随着移动办公的普及，%PRODUCT\_NAME% 支持深度集成钉钉平台，实现钉钉组织架构与用户权限的自动同步，员工无需切换应用即可在钉钉工作台直接访问系统文档，更支持便捷的扫码登录功能，全面打通移动端与PC端的办公场景，为企业打造一站式的智能移动办公解决方案。

## 2\. 操作步骤

### 2.1 登录钉钉开发者平台

1. 使用企业管理员的身份登录钉钉开发者平台（[https://open-dev.dingtalk.com/v1/#/](https://open-dev.dingtalk.com/v1/#/)，如果没有钉钉账号，可以免费申请）登录后请记录下自己企业的`CorpId`，后续步骤中会使用到。本页面以钉钉开发者旧版平台为例进行介绍。
    ![image2021-4-22_17-49-35.png](https://gccndocumentsitestorage.blob.core.chinacloudapi.cn/document-site-files/images/470a8bbd-e525-44a5-a8a2-dc9a77e30084/80212553/image2021-4-22_17-49-35.png?width=700)

#### 2.1.1 创建应用

1. 在钉钉开发者平台，选择「**应用开发>创建应用>委托服务商开发**」进入创建企业内部应用页面。
    ![image](https://gccndocumentsitestorage.blob.core.chinacloudapi.cn/document-site-files/images/53718c5b-c627-4bb8-afaf-3db83ed6dcd8/image-20260313.aeccd2.png?width=700)
2. 在应用创建界面，参考下图所示填写基本信息，最后单击**确定创建**按钮，即可进入应用详情界面。
    ![image](https://gccndocumentsitestorage.blob.core.chinacloudapi.cn/document-site-files/images/53718c5b-c627-4bb8-afaf-3db83ed6dcd8/image-20260313.0fa82b.png)
3. 创建完成后，可以在应用详情界面，查看应用凭证，记录 `AgentId`、`AppKey` 和 `AppSecret`，在集成中会使用到。
    ![image](https://gccndocumentsitestorage.blob.core.chinacloudapi.cn/document-site-files/images/53718c5b-c627-4bb8-afaf-3db83ed6dcd8/image-20260313.f341d8.png?width=700)

#### 2.1.2 配置集成信息

1. 在应用详情界面，单击<strong>开发管理</strong>，然后单击<strong>修改</strong>按钮。
    ![image](https://gccndocumentsitestorage.blob.core.chinacloudapi.cn/document-site-files/images/53718c5b-c627-4bb8-afaf-3db83ed6dcd8/image-20260313.34a346.png?width=700)
2. 接下来配置开发信息。

* **服务器出口IP：** 调用钉钉服务端API的合法的IP列表。若填写的IP不符规范，则无法创建应用。请填写%PRODUCT\_NAME%服务器的IP地址。
* **应用首页地址：** 填写应用首页链接，在移动端工作台点击应用图标会跳转到此页面。
    url格式为：{PortalUrl}/dingtalk/sso?corpid={CorpId}&redirectUri={PortalUrl}。
    * 其中PortalUrl为您实际部署%PRODUCT\_NAME%的域名或IP+端口号。例如： **https://wynportal.grapecity.com**/dingtalk/sso?corpid=xxxxxxx&redirectUri=**https://wynportal.grapecity.com/** 。

3. 填写完成后，单击页面右上角的“ **保存** ”按钮。
    ![PixPin_2025-07-28_11-33-10](https://gccndocumentsitestorage.blob.core.chinacloudapi.cn/document-site-files/images/f5870867-da83-4de9-a405-f6a43930a548/PixPin_2025-07-28_11-33-10.679f6b.png?width=700)

    >type=info
> 注意：若用户需要集成AI对话分析页面，在redirectUri的路径后面要加上/dashboards/chatanalysis，例如：
    > ![image](https://gccndocumentsitestorage.blob.core.chinacloudapi.cn/document-site-files/images/f5870867-da83-4de9-a405-f6a43930a548/image.64f9ea.png)

#### 2.1.3 配置接口权限

1. 在左侧菜单栏单击**权限管理**，然后找到需要的权限点击**立即开通**。
    ![image](https://gccndocumentsitestorage.blob.core.chinacloudapi.cn/document-site-files/images/53718c5b-c627-4bb8-afaf-3db83ed6dcd8/image-20260313.6690e5.png?width=700)
2. 如下图，开通通讯录接口权限
    ![image](https://gccndocumentsitestorage.blob.core.chinacloudapi.cn/document-site-files/images/53718c5b-c627-4bb8-afaf-3db83ed6dcd8/image-20260313.d6f9b7.png?width=700)
3. 然后配置**权限范围**，您可选择全部员工，也可以选择部分员工。比如选择全部员工。
    ![image](https://gccndocumentsitestorage.blob.core.chinacloudapi.cn/document-site-files/images/53718c5b-c627-4bb8-afaf-3db83ed6dcd8/image-20260313.9227ff.png?width=700)

#### 2.1.4 发布应用

1. 在左侧菜单栏，单击**版本管理与发布**，进入应用发布页面，然后单击**确认发布**按钮，即可将应用发布。
    ![image](https://gccndocumentsitestorage.blob.core.chinacloudapi.cn/document-site-files/images/53718c5b-c627-4bb8-afaf-3db83ed6dcd8/image-20260313.98f971.png?width=700)
2. 如可见范围为全部员工，则应用发布时则选择“全部员工”。如果可见范围设置的是部分员工，那么发布时也需要对应的选择“部分员工”。最后保存修改，完成发布。
    ![image](https://gccndocumentsitestorage.blob.core.chinacloudapi.cn/document-site-files/images/53718c5b-c627-4bb8-afaf-3db83ed6dcd8/image-20260313.b90879.png)

### 2.2 系统端配置

1. 在钉钉开发者平台创建并发布微应用后，使用系统管理员（admin） 账户登录%PRODUCT\_NAME%后，依次单击「**系统设置>安全设置>外部用户提供程序**」，选择钉钉，配置集成信息。
    ![PixPin_2025-07-28_16-04-50](https://gccndocumentsitestorage.blob.core.chinacloudapi.cn/document-site-files/images/f5870867-da83-4de9-a405-f6a43930a548/PixPin_2025-07-28_16-04-50.91dc5b.png?width=700)

* **配置项说明：**

    | **配置项目** | **功能** | **说明** |
    | :--- | :--- | :--- |
    | **CorpID** | 企业的CorpID。 | ![image2021-4-22_17-49-35.png](https://gccndocumentsitestorage.blob.core.chinacloudapi.cn/document-site-files/images/470a8bbd-e525-44a5-a8a2-dc9a77e30084/80212553/image2021-4-22_17-49-35.png?width=400) |
    | **AppKey** | 应用凭证AppKey。 | @rows=3:![image](https://gccndocumentsitestorage.blob.core.chinacloudapi.cn/document-site-files/images/53718c5b-c627-4bb8-afaf-3db83ed6dcd8/image-20260316.3ccb2c.png?width=400) |
    | **AppSecret** | 应用凭证AppSecret |
    | **AgentID** | 应用凭证中的AgentID。 |
    | **最大并发请求数** | 同步数据时，单次请求同步的用户数量。 | 建议修改为1。 |
    | **启用扫码登录** | 是否开启二维码登录功能。 | @rows=3:有关扫码登录的更多介绍，请见[钉钉用户扫码登录](/solutions/wyn/help/docs/embedded-integration/mobile-integration/dingtalk/scan-code-to-login)。 |
    | **扫码登录 AppId** | 填写在钉钉应用中创建的QR Code AppId。 |
    | **扫码登录 AppSecret** | 填写在钉钉应用中创建的QR Code AppSecret。 |
    | **启用自动同步** | 是否开启自动同步数据功能。<br>同步数据指的是将钉钉中的用户数据同步到 %PRODUCT\_NAME% 中。 | - |
    | **同步时间间隔** | 设置自动同步数据的时间间隔，必须填入正整数，单位“小时”。<br> 输入非正整数时，均按1小时计算。 | - |

2. 我们将之前记录的 `CorpID`、`AgentId`、`AppKey`和`AppSecret`信息填入对1应输入框中。
    并开启自动同步数据功能，将时间间隔设置为1小时，最后单击**保存**按钮保存设置。
    ![PixPin_2025-07-28_11-48-53](https://gccndocumentsitestorage.blob.core.chinacloudapi.cn/document-site-files/images/f5870867-da83-4de9-a405-f6a43930a548/PixPin_2025-07-28_11-48-53.aacc65.png?width=700)
3. 保存之后系统检测到您开启了**自动同步**数据功能（约15分钟后），会立即进行首次的数据同步。之后会按照设置的间隔进行自动同步。
    1）为了可以立即将钉钉中的用户数据同步到系统中，我们可手动同步数据。
    ![PixPin_2025-07-28_11-50-53](https://gccndocumentsitestorage.blob.core.chinacloudapi.cn/document-site-files/images/f5870867-da83-4de9-a405-f6a43930a548/PixPin_2025-07-28_11-50-53.8eefc9.png)
    2）提示同步成功。
    ![PixPin_2025-07-28_11-50-32](https://gccndocumentsitestorage.blob.core.chinacloudapi.cn/document-site-files/images/f5870867-da83-4de9-a405-f6a43930a548/PixPin_2025-07-28_11-50-32.eb858b.png)

### 2.3 查看钉钉映射

1. 此时整个配置过程基本完成，我们到 %PRODUCT\_NAME% 系统中来看一下钉钉用户的映射情况。
    1）可见钉钉是作为全局下的一个单独组织存在。
    ![PixPin_2025-07-28_11-52-47](https://gccndocumentsitestorage.blob.core.chinacloudapi.cn/document-site-files/images/f5870867-da83-4de9-a405-f6a43930a548/PixPin_2025-07-28_11-52-47.00c14c.png?width=700)
    2）钉钉中的角色全部直接挂在“钉钉”总组织下。
    ![PixPin_2025-07-28_11-54-00](https://gccndocumentsitestorage.blob.core.chinacloudapi.cn/document-site-files/images/f5870867-da83-4de9-a405-f6a43930a548/PixPin_2025-07-28_11-54-00.c9ba8f.png?width=700)
    3）从用户管理可查看组织或角色的用户成员。
    ![PixPin_2025-07-28_12-01-51](https://gccndocumentsitestorage.blob.core.chinacloudapi.cn/document-site-files/images/f5870867-da83-4de9-a405-f6a43930a548/PixPin_2025-07-28_12-01-51.f18aad.png?width=700)

    >type=info
> 

> 

> 

> **提示：** 如您需要在钉钉组织中添加新的组织、角色或用户，推荐直接在钉钉端操作，因为%PRODUCT\_NAME%会通过数据同步将钉钉端的最新组织结构覆盖到系统中。

### 2.4 钉钉登录

1. 当在手机中登录钉钉，可以在**工作台**栏中看到自己创建的应用（默认在未分组应用下），单击应用图标，选择组织后即可自动登录 %PRODUCT\_NAME%。
    ![PixPin_2025-07-28_16-29-34](https://gccndocumentsitestorage.blob.core.chinacloudapi.cn/document-site-files/images/f5870867-da83-4de9-a405-f6a43930a548/PixPin_2025-07-28_16-29-34.5ea033.png) ![PixPin_2025-07-28_16-33-03](https://gccndocumentsitestorage.blob.core.chinacloudapi.cn/document-site-files/images/f5870867-da83-4de9-a405-f6a43930a548/PixPin_2025-07-28_16-33-03.0d29fd.png) ![PixPin_2025-07-28_12-20-23](https://gccndocumentsitestorage.blob.core.chinacloudapi.cn/document-site-files/images/f5870867-da83-4de9-a405-f6a43930a548/PixPin_2025-07-28_12-20-23.1ea312.png)

    >type=info
> 

> 

> 

> **注意：**
> \> 1）部分安卓系统手机在钉钉中单击 %PRODUCT\_NAME% 应用的图标后，发现浏览器长时间处于一直在跳转的状态而无法登录到 %PRODUCT\_NAME%，此种情况是由于钉钉内置的UC浏览器问题导致。
> \> 2）如遇到这种情况，您需要在任务管理器中停止`WynService`服务，然后修改 %PRODUCT\_NAME% 的配置文件。
> \> 3）使用记事本程序打开系统配置文件`Wyn.conf`和参考文件`Wyn.conf.sample`。
> \> 4）将参考文件中的Cookie相关内容拷贝到配置文件对应节点下，并将SameSite的值改为“<strong>None</strong>”，如下图所示。
> \> ![image2022-5-28_16-14-29.png](https://gccndocumentsitestorage.blob.core.chinacloudapi.cn/document-site-files/images/470a8bbd-e525-44a5-a8a2-dc9a77e30084/80212553/image2022-5-28_16-14-29.png?width=800)
> \> 5）修改完成后保存配置文件，然后再启动`WynService`服务即可。