Python 仪表板缓冲的Api键
我正在使用dashing.io仪表板,我想用python中的requests库发出post请求,将数据放入小部件中 但它一直向我发回401错误和无效的API密钥。我不明白为什么,也没有真正了解auth_令牌和api密钥之间的区别 这是我的密码:Python 仪表板缓冲的Api键,python,http-status-code-401,api-key,dashing,Python,Http Status Code 401,Api Key,Dashing,我正在使用dashing.io仪表板,我想用python中的requests库发出post请求,将数据放入小部件中 但它一直向我发回401错误和无效的API密钥。我不明白为什么,也没有真正了解auth_令牌和api密钥之间的区别 这是我的密码: import json import requests dashboard_url = "http://localhost:3030" widget_id = 'my_widget_id' widget_url = dashboard_url +
import json
import requests
dashboard_url = "http://localhost:3030"
widget_id = 'my_widget_id'
widget_url = dashboard_url + '/widgets/my_widget_id'
data = {'name' : 'thomas','id' : 'bonjour','city' : 'cerfontaine'}
data = json.dumps(data)
headers ={'Content-Type':'application/json', 'Accept':'text/plain',
'Authorization':'XYZ'}
try:
r = requests.post(widget_url, data, headers=headers)
print r.status_code
print r.json()
print r.text
except:
r = requests.post(widget_url, data, headers=headers)
print 'Dashing update failed'
print r.text
我在config.ru中的代码身份验证令牌也是XYZ。
你们能帮我吗?你们需要在有效载荷中包含密钥,而不是标题
data = {
'name' : 'thomas',
'id' : 'bonjour',
'city' : 'cerfontaine',
'auth_token' : YOUR_AUTH_TOKEN_HERE
}
请参见我的Django示例您没有发送正确的API密钥