尝试使用python访问API时出现无效的令牌错误

时间:2020-09-05 04:29:56

标签: python api curl authorization

我正在尝试访问一个API:

SELECT d.`msn`, MAX(d.`kwh_t`) AS 'Previous KWH', MAX(d2.`kwh_t`) AS 'New  KwH', MIN(d.`data_date_time`), MAX(d.`data_date_time`) FROM `mdc_meters_data` d 
INNER JOIN `mdc_meters_data` d2 ON d2.`id` = d.`id` +1
WHERE d2.`kwh_t` > d.`kwh_t` AND d.`s_type` = 'WAPDA' AND d.`data_date_time` >='2020-09-05 00:00:00' AND d.`data_date_time`<='2020-09-05 23:59:59'
GROUP BY d.`data_date_time`, d2.`data_date_time`

我正在使用Python并尝试过此操作:

curl "api_endpoint_here"
  -H "Authorization: Token token=YOURAPIKEY"

我用实际的API密钥代替了my_API_KEY。

我收到一条错误消息:“未经授权-您的API密钥错误” 密钥正确。

1 个答案:

答案 0 :(得分:0)

这有助于: 标头= {'授权':'令牌my_API_KEY'}