我正在尝试使用 Python 的 requests 模块向Proactive Events API发出请求。
但是,我总是收到范围无效的响应。任何人都可以帮忙吗?我究竟做错了什么?我的代码如下所示:
@ask.launch
def launch():
content_type = "application/x-www-form-urlencoded;charset=utf-8"
client_id = "amzn1.application-oa2-client.6a48XXXXXXX408"
client_secret = "592XXXXxxxxxxx6"
scope = "alexa::proactive_events"
grant_type = "client_credentials"
data = {"grant_type": grant_type, "client_id": client_id, "client_secret": client_secret, "scope": scope}
r = requests.post("https://api.amazon.com/auth/O2/token", data=data, headers={"content-type": content_type})
speech = render_template("welcome")
reprompt = render_template("welcome_reprompt")
return question(speech).reprompt(reprompt)
这就是我得到的回应:
{'error_description': 'The request has an invalid parameter : scope', 'error': 'invalid_scope'}