我想从我的Jupyther Notebook中调用Adobe Analytics API 2.0。我不需要服务器和adobe(或类似)之间的任何“永久”身份验证,我只想获得一些(大量)数据进行分析。
我已经创建了这里描述的API密钥集成(https://www.adobe.io/authentication/auth-methods.html#!AdobeDocs/adobeio-auth/master/AuthenticationOverview/APIKeyIntegration.md)
如果我发送一个示例电话,让我们说:
r = requests.get("https://analytics.adobe.io/api/myID/dimensions?rsid=myreportsuite&locale=en_US&segmentable=true&reportable=true&classifiable=false")
显然,我得到以下答案:
'{"error_code":"403010","message":"Oauth token is missing."}\n'
如何在我的请求中包含我的Oauth令牌?
你需要将它们放在headers
中,特别是通过提供headers
函数的get
参数的字典作为记录的here
url = 'https://api.github.com/some/endpoint'
my_api_key = 'thisismyapikey9393'
my_product_name = 'my_app_0.1'
headers = {
'x-api-key' : my_api_key,
'x-product' : my_product_name
}
r = requests.get(url, headers=headers)
我从adobe链接中获取了Step 3: Try It
的标题名称。
curl'https://stock.adobe.io/Rest/Media/1/Search/Files?locale=en_US%26search_parameters%5Bwords%5D=kittens'-H'x-api-key:myAPIKey'-H'x-product:myTestApp1.0'