davidmroth / AlexaPi

Alexa client for all your devices!
MIT License
1 stars 2 forks source link

Missing config info #1

Closed amahlaka closed 8 years ago

amahlaka commented 8 years ago

Missing info about newly required config parametres: AuthUrl, BaseUrl and API_Version related file: /src/alexa/http/http.py

avs_auth_url = shared.config['alexa']['AuthUrl']
avs_base_url = shared.config['alexa']['BaseUrl']
API_VERSION = shared.config['alexa']['API_Version']
amahlaka commented 8 years ago

AAND i found it by trying out random urls AuthUrl: "https://api.amazon.com" BaseUrl: "https://avs-alexa-na.amazon.com"

amahlaka commented 8 years ago

and found some more missing configs, like EventPath

davidmroth commented 8 years ago

Did you sign up here first? https://developer.amazon.com/login.html

davidmroth commented 8 years ago

Here is my config (developer info redacted)

# Rename this file to config.yaml and fill in the fields

sound:
  # Name of your microphone/soundcard in arecord -L
  # you can also try setting it to 'default'
  device: "plughw:0"

# Amazon Alexa settings
debug:
        alexa: 'debug'
        #hpack: 'debug'
        #hyper: 'debug'
        #requests: 'debug'

alexa:
        AuthUrl: "https://api.amazon.com"
        BaseUrl: "https://avs-alexa-na.amazon.com"
        EventPath: "/events"
        API_Version: "v20160207"
        Client_ID: ""
        Client_Secret: ""
        ProductID: "my_device"
        Security_Profile_Description: ""
        Security_Profile_ID: ""
        refresh_token: ""

sphinx:
  trigger_phrase: alexa

raspberrypi:
  # GPIO Pin with button connected
  button: 18
  # GPIO Pin for the playback/activity light
  plb_light: &plb_light 24
  # GPIO Pin for the recording light
  rec_light: &rec_light 25
  # GPIO Pins with LED's connected
  lights: [*plb_light, *rec_light]
amahlaka commented 8 years ago

alexa: Client_ID: "xx" Client_Secret: "x" ProductID: "AlexaPi" Security_Profile_Description: "AlexaPi description" Security_Profile_ID: "amzn1.application.x" refresh_token: "x" AuthUrl: "https://api.amazon.com" BaseUrl: "https://avs-alexa-na.amazon.com" EventPath: "/events" API_Version: "v20160207"

@davidmroth

davidmroth commented 8 years ago

Did you run the python ./auth_web.py command to authorize your hardware?

amahlaka commented 8 years ago

yes

davidmroth commented 8 years ago

Please enable logging:

# Amazon Alexa settings
debug:`
       alexa: 'debug'
        #hpack: 'debug'
        #hyper: 'debug'
        #requests: 'debug'
amahlaka commented 8 years ago
2016-11-24 20:42:33,619 - alexa.http.http - INFO - Checking Internet Connection...
2016-11-24 20:42:33,622 - alexa.http.http - INFO - Connection OK
2016-11-24 20:42:34,778 - alexa.http.http - ERROR - <function <lambda> at 0x75691d30>(): Could not open AVS downchannel stream - https://avs-alexa-na.amazon.com/v20160207/directives
davidmroth commented 8 years ago

Can you comment out line 99 of src/alexa/http/http.py?
`

self.__open_downchannel_stream()

`

Technically, this isn't working anyway, so it shouldn't be a problem. Pretty sure you're going to run into another issue. Still thinking something could be wrong with your config or developer settings.

amahlaka commented 8 years ago
2016-11-24 20:55:05,407 - alexa.http.http - ERROR - error: [Errno 32] Broken pipe
Traceback (most recent call last):
  File "/opt/AlexaPi/src/alexa/http/http.py", line 191, in post
    request = self.__session.post(full_url, headers=headers, files=payload, stream=True, timeout=None)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 522, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 475, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 596, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/hyper/contrib.py", line 78, in send
    request.headers
  File "/usr/local/lib/python2.7/dist-packages/hyper/common/connection.py", line 103, in request
    method=method, url=url, body=body, headers=headers
  File "/usr/local/lib/python2.7/dist-packages/hyper/http11/connection.py", line 183, in request
    self._send_headers(method, url, headers)
  File "/usr/local/lib/python2.7/dist-packages/hyper/http11/connection.py", line 228, in _send_headers
    self._sock.send(b' '.join([method, url, b'HTTP/1.1\r\n']))
  File "/usr/lib/python2.7/ssl.py", line 667, in send
    v = self._sslobj.write(data)

after i say Alexa and alexa says yes, it says instantly after that: error processing request

davidmroth commented 8 years ago

I'm almost positive Amazon is rejecting your security settings (broken pipe). Can you checkout the master branch and see if you have the same problem? Or maybe you have done that already. Let me know.

BTW, did you install the hyper package? My guess is you did. Just checking though...

amahlaka commented 8 years ago

hmm, maybe i try with new security profile

davidmroth commented 8 years ago

I would first checkout another branch and verify if the problem persists. That will isolate the issue to your profile or my branch. Again, I checked out the branch and it working for me, so something is different.

Let me know what you find...

amahlaka commented 8 years ago

i had a working installation on the master branch

amahlaka commented 8 years ago
Traceback (most recent call last):
  File "./auth_web.py", line 12, in <module>
    import alexapi.config
ImportError: No module named alexapi.config
davidmroth commented 8 years ago

Probably doesn't mean much, but I noticed your line 191 isn't the same as my line 191. Just to make sure, can you post line 191?

amahlaka commented 8 years ago

i made a clean reinstall just now

davidmroth commented 8 years ago
Traceback (most recent call last):
  File "./auth_web.py", line 12, in <module>
    import alexapi.config
ImportError: No module named alexapi.config

change import alexapi.config to from alexa.helper.config import config and then remove lines:

with open(alexapi.config.filename, 'r') as stream:
       config = yaml.load(stream)
amahlaka commented 8 years ago

!! Traceback (most recent call last): !! File "main.py", line 221, in start() !! File "main.py", line 192, in start if shared.debug == False: !! AttributeError: 'module' object has no attribute 'debug'

amahlaka commented 8 years ago

hmm i did the changes to auth_web, but after i click yes on the page it gives me error 500

davidmroth commented 8 years ago

Add to line: 20

else:
    Debug = False

to src/alexa/helper/shared.py

Should look like this when you're done:

#Get config
if config and 'debug' in config and 'alexa' in config['debug']:
         if config['debug']['alexa']: debug = True
else:
        debug = False

Also, if you update your config.yaml with these line:

# Amazon Alexa settings
debug:
       alexa: 'debug'
       #hpack: 'debug'
       #hyper: 'debug'
       #requests: 'debug'
amahlaka commented 8 years ago

hmm, still getting problems with the auth_web

davidmroth commented 8 years ago

What problem now?

amahlaka commented 8 years ago

Error 500 after clicking Yes on the auth page

amahlaka commented 8 years ago

btw, are you in the alexapi Gitter?

davidmroth commented 8 years ago

image

What do you have configured in your developer settings?

amahlaka commented 8 years ago

https://gyazo.com/2b12ae2c260dfd7cbb17c43beba3fc20

davidmroth commented 8 years ago

Make it look like mine, but use the IP address of your device.

davidmroth commented 8 years ago

Send me a screen shot. BTW, you can paste images directly into the comment box.

amahlaka commented 8 years ago

Error: A URL must be between 1 and 2000 characters.

davidmroth commented 8 years ago

What? Doesn't make sense. Post an image of what you're trying to save. ...before you press save.

amahlaka commented 8 years ago

image

davidmroth commented 8 years ago

You probably need to remove the blank lines.

amahlaka commented 8 years ago

i cant

davidmroth commented 8 years ago

Right, just checked. Just duplicate the settings in the blank boxes

davidmroth commented 8 years ago

Wait... I'm getting the same error. Sorry... Let me see what the issue is... BRB

amahlaka commented 8 years ago

when did you last push?

davidmroth commented 8 years ago

So, here's the deal. Its been a few months since I've had to use this process. Hence the reason why my code base was not in sync with ./auth_web.py.

Looking into this now... Should have a fix shortly...

amahlaka commented 8 years ago

image

amahlaka commented 8 years ago

you need that :p

davidmroth commented 8 years ago

Ok, fixed!

Please do a git pull from the avs_v2 branch.

davidmroth commented 8 years ago

Yeah, I deserve that... :-(

BTW, it's not like I didn't warn you... This is far from complete.

amahlaka commented 8 years ago

hmm,

 alexa.http.http - ERROR - <function <lambda> at 0x755fbd30>(): Could not open AVS downchannel stream - https://avs-alexa-na.amazon.com/v20160207/directives
Traceback (most recent call last):
  File "/opt/AlexaPi/src/alexa/http/http.py", line 146, in __open_downchannel_stream
    response = self.__session.get(full_url, headers=headers, stream=True, timeout=None)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 488, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 475, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 596, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/hyper/contrib.py", line 80, in send
    resp = conn.get_response()
  File "/usr/local/lib/python2.7/dist-packages/hyper/common/connection.py", line 129, in get_response
    return self._conn.get_response(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/hyper/http11/connection.py", line 204, in get_response
    response = self.parser.parse_response(self._sock.buffer)
  File "/usr/local/lib/python2.7/dist-packages/hyper/http11/parser.py", line 52, in parse_response
    version, status, reason = temp_buffer[0:index].split(None, 2)
ValueError: need more than 2 values to unpack
2016-11-24 22:30:04,620 - alexa.http.http - ERROR - error: need more than 2 values to unpack
Traceback (most recent call last):
  File "/opt/AlexaPi/src/alexa/http/http.py", line 146, in __open_downchannel_stream
    response = self.__session.get(full_url, headers=headers, stream=True, timeout=None)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 488, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 475, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 596, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/hyper/contrib.py", line 80, in send
    resp = conn.get_response()
  File "/usr/local/lib/python2.7/dist-packages/hyper/common/connection.py", line 129, in get_response
    return self._conn.get_response(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/hyper/http11/connection.py", line 204, in get_response
    response = self.parser.parse_response(self._sock.buffer)
  File "/usr/local/lib/python2.7/dist-packages/hyper/http11/parser.py", line 52, in parse_response
    version, status, reason = temp_buffer[0:index].split(None, 2)
ValueError: need more than 2 values to unpack
2016-11-24 22:30:04,782 - alexa.http.http - ERROR - <function <lambda> at 0x755fbd30>(): Could not synchronize state - %s
Traceback (most recent call last):
  File "/opt/AlexaPi/src/alexa/http/http.py", line 164, in __synchronize_state
    request = self.__session.post(full_url, headers=headers, files=payload, stream=True, timeout=None)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 522, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 475, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 596, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/hyper/contrib.py", line 80, in send
    resp = conn.get_response()
  File "/usr/local/lib/python2.7/dist-packages/hyper/common/connection.py", line 129, in get_response
    return self._conn.get_response(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/hyper/http11/connection.py", line 204, in get_response
    response = self.parser.parse_response(self._sock.buffer)
  File "/usr/local/lib/python2.7/dist-packages/hyper/http11/parser.py", line 52, in parse_response
    version, status, reason = temp_buffer[0:index].split(None, 2)
ValueError: need more than 2 values to unpack
2016-11-24 22:30:04,785 - alexa.http.http - ERROR - error: need more than 2 values to unpack
Traceback (most recent call last):
  File "/opt/AlexaPi/src/alexa/http/http.py", line 164, in __synchronize_state
    request = self.__session.post(full_url, headers=headers, files=payload, stream=True, timeout=None)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 522, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 475, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 596, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/hyper/contrib.py", line 80, in send
    resp = conn.get_response()
  File "/usr/local/lib/python2.7/dist-packages/hyper/common/connection.py", line 129, in get_response
    return self._conn.get_response(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/hyper/http11/connection.py", line 204, in get_response
    response = self.parser.parse_response(self._sock.buffer)
  File "/usr/local/lib/python2.7/dist-packages/hyper/http11/parser.py", line 52, in parse_response
    version, status, reason = temp_buffer[0:index].split(None, 2)
ValueError: need more than 2 values to unpack
2016-11-24 22:30:14,512 - alexa.http.http - ERROR - <function <lambda> at 0x755fbd30>(): Could not post to: https://avs-alexa-na.amazon.com/v20160207/events/
Traceback (most recent call last):
  File "/opt/AlexaPi/src/alexa/http/http.py", line 191, in post
    request = self.__session.post(full_url, headers=headers, files=payload, stream=True, timeout=None)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 522, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 475, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 596, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/hyper/contrib.py", line 78, in send
    request.headers
  File "/usr/local/lib/python2.7/dist-packages/hyper/common/connection.py", line 103, in request
    method=method, url=url, body=body, headers=headers
  File "/usr/local/lib/python2.7/dist-packages/hyper/http11/connection.py", line 183, in request
    self._send_headers(method, url, headers)
  File "/usr/local/lib/python2.7/dist-packages/hyper/http11/connection.py", line 228, in _send_headers
    self._sock.send(b' '.join([method, url, b'HTTP/1.1\r\n']))
  File "/usr/lib/python2.7/ssl.py", line 667, in send
    v = self._sslobj.write(data)
error: [Errno 32] Broken pipe
2016-11-24 22:30:14,516 - alexa.http.http - ERROR - error: [Errno 32] Broken pipe
Traceback (most recent call last):
  File "/opt/AlexaPi/src/alexa/http/http.py", line 191, in post
    request = self.__session.post(full_url, headers=headers, files=payload, stream=True, timeout=None)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 522, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 475, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 596, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/hyper/contrib.py", line 78, in send
    request.headers
  File "/usr/local/lib/python2.7/dist-packages/hyper/common/connection.py", line 103, in request
    method=method, url=url, body=body, headers=headers
  File "/usr/local/lib/python2.7/dist-packages/hyper/http11/connection.py", line 183, in request
    self._send_headers(method, url, headers)
  File "/usr/local/lib/python2.7/dist-packages/hyper/http11/connection.py", line 228, in _send_headers
    self._sock.send(b' '.join([method, url, b'HTTP/1.1\r\n']))
  File "/usr/lib/python2.7/ssl.py", line 667, in send
    v = self._sslobj.write(data)
error: [Errno 32] Broken pipe
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/opt/AlexaPi/src/alexa/avs/directive_dispatcher.py", line 76, in processor
    log.debug("{}(process_response Error){} Status Code: {} - {}".format(shared.bcolors.WARNING, shared.bcolors.ENDC, r.status_code, r.text))
AttributeError: 'bool' object has no attribute 'status_code'
amahlaka commented 8 years ago

hmm i changed the port in the auth_web to 5050 as my 5000 is in use btw, it works after your update but still after i give alexa command, it says error processing

davidmroth commented 8 years ago

Are you one a Windows or Linux?

amahlaka commented 8 years ago

im on rasbian distro of debian on raspi

davidmroth commented 8 years ago

If port 5000 is in use, it could mean you have another python instance running. Can you run the command: ps aux | grep python?

amahlaka commented 8 years ago

i know what is using it tho

davidmroth commented 8 years ago

Oh. Got it. Sorry