1.在开发者后台配置相关信息
2.获取钉钉用户基本信息
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time: 2021/3/19 10:00
# @Author: w_fei
import requests
import json
app_key = 'dingscjivkrwr7nl3jnv'
app_secret = 'yAqUeWaPuKtXWf9v3LZY60vPyQT00C0nS3m8MmKjaaGoacbm-fpEqU_eS2Odr4zd'
agent_id = '1138712045'
def get_access():
"""
获取token
:return:
"""
url = "https://oapi.dingtalk.com/gettoken?appkey={0}&appsecret={1}".format(app_key, app_secret)
jo = json.loads(requests.get(url).text)
return jo['access_token']
def get_dp(token):
"""
获取部门列表
:param token:
:return:
"""
url = "https://oapi.dingtalk.com/department/list?access_token=" + token
# url = "https://oapi.dingtalk.com/topapi/v2/department/get?access_token=" + token
dp = json.loads(requests.g