如何验证django中的API密钥?im使用rapidapi和他们有这个密钥,我如何授权它与url
views.py
def thanks(request):
url = "https://webknox-trivia-knowledge-facts-v1.p.rapidapi.com/trivia/random"
headers = {
'x-rapidapi-host': "webknox-trivia-knowledge-facts-v1.p.rapidapi.com",
'x-rapidapi-key': "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
r = requests.get(url)
json_data = json.loads(r.text)
print(json_data)
return render(request,'portofolio/thankyou.html',headers)
打印返回“'message':'缺少RapidAPI应用程序密钥。转到https://docs.rapidapi.com/docs/keys了解如何获取API应用程序密钥。'}”我有密钥,如何授权?并在我的Django模板中使用它!提前感谢:)
1条答案
按热度按时间8oomwypt1#
您需要将头发送到rapidapi: