如何基于python對接釘釘并獲取access_token
1.首先注冊應(yīng)用,獲取 appkey、appsecret
api_url = 'https://oapi.dingtalk.com/gettoken?appkey=%s&appsecret=%s'%(appkey,appsecret)def get_token(): # try: res = requests.get(api_url) if res.status_code == 200: str_res = res.text token = (json.loads(str_res)).get(’access_token’) return token
2.此時(shí)拿到的token就是access_token,可以用它來發(fā)送請求了
def departList(): # 所有部門信息 url = ’https://oapi.dingtalk.com/department/list?access_token={}’.format(get_token()) ret = json.loads(requests.get(url).text) department = ret.get(’department’) departList = [] for department_info in department: departdict = {} departdict[’name’] = department_info.get(’name’) departdict[’id’] = department_info.get(’id’) departdict[’parentid’] = department_info.get(’parentid’) departList.append(departdict) return departList
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. asp文件用什么軟件編輯2. PHP基礎(chǔ)之生成器4——比較生成器和迭代器對象3. CentOS郵箱服務(wù)器搭建系列——SMTP服務(wù)器的構(gòu)建( Postfix )4. Docker 啟動(dòng)Redis 并設(shè)置密碼的操作5. ASP新手必備的基礎(chǔ)知識(shí)6. Vue axios獲取token臨時(shí)令牌封裝案例7. vue+element開發(fā)一個(gè)谷歌插件的全過程8. Spring如何替換掉默認(rèn)common-logging.jar9. 利用CSS制作3D動(dòng)畫10. JAVA 實(shí)現(xiàn)延遲隊(duì)列的方法

網(wǎng)公網(wǎng)安備