问题
I'm following amazon's guide in creating a python application that can access Alexa. I have obtained my access/refresh tokens, and am trying to open a HTTP2 connection with AVS.
Since I'm doing this in python, I've utilized the requests library to manage all my HTTP connections stuff. However, I can't seem to get past the first step of opening a connection with AVS. I think the problem is simply my syntax in my request, as I'm not sure how certain elements of the get request are supposed to be represented in the HTTP call. Specifically,
To establish a downchannel stream your client must make a GET request to /{{API version}}/directives within 10 seconds of opening the connection with AVS. The request should look like this:
1 :method = GET
2 :scheme = https
3 :path = /{{API version}}/directives
4 authorization = Bearer {{YOUR_ACCESS_TOKEN}}
To start, the part of the instructions where it states
...within 10 seconds of opening the connection with AVS
Would that be a separate call from the GET request to /API version/directives
? If so, what would that look like?
Then, for the actual call to /API version/directives
, my code looks like this (Python):
def establishDownstream():
url = "https://avs-alexa-na.amazon.com/v20160207/directives"
foo = "Bearer " + ACCESS_KEY
payload = {"authorization" : foo}
g = requests.get(url, params=payload)
My reasoning is that since it's a requests.get()
call, the :method = GET
is taken care of, since the url starts with https://
, the :scheme = https
is taken care of, and the url itself takes care of the path (again, correct me if I'm wrong). Then I simply need to pass my access key as value to authorization
, which I do through params
. However, this is not leading to any success (the specific error message is requests.exceptions.SSLError: EOF occurred in violation of protocol (_ssl.c:590)
).
I really don't know what's going on here. All the guides I found online regarding HTTP request protocols structure their requests in a block form, not through a python library, so I have no examples to work off of.
Any help is appreciated!
来源:https://stackoverflow.com/questions/37952758/establishing-http2-connection-with-avs-python-requests-library