0

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!

David Cai
  • 31
  • 4
  • I don't think requests supports http 2 – jonrsharpe Jun 21 '16 at 19:15
  • I was under the impression that HTTP/2 was primarily an "under the hood" update so to speak, and the most of the protocols such as GET and POST were the same...? Also, `requests` worked fine when I used it to grab the access token, also from Amazon. – David Cai Jun 21 '16 at 19:21
  • Have you searched for the error message? See e.g. https://github.com/kennethreitz/requests/issues/3006 – jonrsharpe Jun 21 '16 at 19:22
  • @jonrsharpe, you are correct, it doesn't. There is a lib hyper that does but it is very much in the alpha stages http://hyper.readthedocs.io/en/latest/quickstart.html – Padraic Cunningham Jun 21 '16 at 19:53
  • The docs actually encourage hyper for use with python https://github.com/http2/http2-spec/wiki/Implementations – Padraic Cunningham Jun 21 '16 at 19:54

0 Answers0