- 确保已经获取到了 oAuth 令牌。
- 使用 oAuth 令牌作为请求头的 Authorization 信息发送 GET 请求,例如:
import requests
# 替换成实际值
tenant_url = 'https://.acumatica.com'
client_id = '***'
client_secret = '***'
username = '***'
password = '***'
# 获取 access_token
token_request_url = f'{tenant_url}/identity/connect/token'
response = requests.post(
token_request_url,
data={
'client_id': client_id,
'client_secret': client_secret,
'username': username,
'password': password,
'grant_type': 'password'
}
)
response_data = response.json()
access_token = response_data['access_token']
# 发送 GET 请求,其中 headers 中包含了 Authorization 信息
headers = {
'Authorization': f'Bearer {access_token}'
}
request_url = f'{tenant_url}/entity/Default/18.200.001/GeneralLedgerAccount'
response = requests.get(
request_url,
headers=headers
)
accounts_data = response.json()