我需要使用Python从App的API中提取一些数据。然而,我无法连接。我检查了API密钥和“文档”。有人知道我如何通过他们的API连接吗?我一直有401个未经授权的访问错误。
https://support.appannie.com/hc/en-us/articles/204208864-3-Authentication
import json
import requests
url = 'https://api.appannie.com/v1.2/apps/ios/app/12345678/reviews?start_date=2012-01-01&end_date=2012-02-01&countries=US'
key = 'Authorization: bearer b7e26.........'
response = requests.get(url, key) #After running up to this I get 401
data = json.loads(response.json()) #data is a dictionary发布于 2016-07-28 23:43:10
您需要在HTTP头中指定api密钥:
response = requests.get(url,
headers={'Authorization':'bearer b7e26.........'})发布于 2017-06-16 22:18:06
这是一个答案而不是一个问题。我错误地评论了我的答案。
(一般资料。希望能帮上忙)。在标题中调用API键:当我在:之后、bearer之前以及bearer和API KEY之间添加一个空格时,它对我起了作用:
'Authorization': 'bearer API KEY'
不要使用应用程序名。您需要应用程序ID。
app id的步骤:
https://stackoverflow.com/questions/38648328
复制相似问题