獲取釘釘開發access_token


def access_token():
    p1="data/dingtalk/token.txt"
    b1=True#是否請求token
    re=""
    if os.path.exists(p1):
        r=txtread(p1)
        a1=json.loads(r)
        t1=a1["time"]
        tk=a1["access_token"]
        if t1<int(time.time()):
            b1=True
        else:
            b1=False
            re=tk
    #b1為true 請求更新token 
    if b1:
        print("正在獲取token")
     # app_key="####"
     # app_secret="###"
     # url="https://oapi.dingtalk.com/gettoken?appkey={0}&appsecret={1}".format(app_key,app_secret) r=requests.get(url) a1=json.loads(r.text) tk=a1["access_token"] t1=int(time.time())+7000 a2={"access_token":tk,"time":t1} txtwrite(p1,json.dumps(a2)) re=tk return re

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM