Python调用飞书Api上传本表格
import requests
class FeishuApi():
def __init__(self,app_id,app_secret,code_x):
self.app_id = app_id
self.app_secret = app_secret
self.code_x = code_x
def app_access_token(self):
data = {
"app_id":self.app_id,
"app_secret":self.app_secret
}
app_token = requests.post("https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal", json=data)
return app_token.json()
def user_access_token(self):
data = {
"grant_type": "authorization_code",
"code": self.code_x
}
headers = {
"Authorization":"Bearer "+self.app_access_token()["tenant_access_token"]
}
user_token = requests.post("https://open.feishu.cn/open-apis/authen/v1/access_token", json=data ,headers=headers)
return user_token.json()["data"]["access_token"]
if __name__ == '__main__':
Fa = FeishuApi(app_id="",
app_secret="",
code_x = "")
user_token = Fa.user_access_token()
print(user_token)
|