[英]Python3 - Get Request with Secret
I am trying to send a get request to Airtable to get metadata but I keep getting errors.我正在尝试向Airtable 发送获取请求以获取元数据,但我不断收到错误消息。
I have tried the below.我已经尝试过以下方法。
base_schema_url = 'https://api.airtable.com/v0/meta/bases/BaseId(replaced this)/tables'
secret_meta_token = '123'
#attempt 1
r = requests.get(base_schema_url, headers={'Authorization': secret_meta_token})
print(r.text)
#attempt 2
r = requests.get(base_schema_url,
headers={'Content-Type':'application/json',
'Authorization': 'Bearer {}'.format(secret_meta_token)})
print(r.text)
#attempt 3
header = {'PRIVATE-TOKEN': secret_meta_token}
r = requests.get(base_schema_url, headers=header)
print(r.text)
I have a feeling it's because I need to pass in the user API + the Meta token but I'm not too sure how to do it.我有一种感觉,因为我需要传入用户 API + Meta 令牌,但我不太确定该怎么做。
The metadata API uses a separate key that you need to send a formal request to the Airtable team by registering at the link provided at the top of the page.元数据 API 使用单独的密钥,您需要通过在页面顶部提供的链接进行注册来向 Airtable 团队发送正式请求。
import requests
user_account_api = xxx
meta_api = xxx
base_id = xxx
headers = {
"Authorization":f"Bearer {user_account_api}",
"x-airtable-client-secret": meta_api
}
response = requests.get(f"https://api.airtable.com/v0/meta/bases/{base_id}/tables", headers=headers)
print(response.text)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.