Manishearth / ChatExchange

A Python API for talking to Stack Exchange chat
Apache License 2.0
65 stars 36 forks source link

[Support] When running something using this CE engine in PyCharm, "failed to get `usr` cookie from Stack Exchange OpenID" #135

Closed teward closed 7 years ago

teward commented 7 years ago

I'm not sure if this is a PyCharm issue or not, but what cases can trigger a "None" to be received by ChatExchange engine here, which would cause a failure case? I'm trying to debug some things with SmokeDetector which would require a full debugger instance, and trying to run this in PyCharm's debugger to define my breakpoints, but I always get that "failed to get usr cookie from Stack Exchange OpenID" error, just trying to determine what could cause this.

ByteCommander commented 7 years ago

I haven't touched any of that code in over a year and also am too busy currently to dig back in, but it would be helpful if you could find out and tell where exactly (which method call) a None is returned or that Error is outputted. Also, as your question suggests that it does not err if you run it outside PyCharm, you should verify what Python environment PyCharm uses to execute the code. Compare Python version, installed packages, environment variables etc...

teward commented 7 years ago

Well, this is how PyCharm is executing the SmokeDetector scripts: /usr/bin/python2.7 /opt/jetbrains/pycharm/helpers/pydev/pydevd.py --cmd-line --multiproc --save-signatures --qt-support --client 127.0.0.1 --port 43040 --file nocrash.py

In SmokeDetector, it's using the following class from ChatExchange: from ChatExchange.chatexchange.client import Client, creates a logon of the Client for three chat areas (stackexchange.com, meta.stackexchange.com, and stackoverflow.com) with three separate Client items in the global vars, and whenever we call the first login call, with valid credentials, triggers this traceback:

LoginError: failed to get `usr` cookie from Stack Exchange OpenID
2017-02-10 03:56:15.271808 UTC
  File "/opt/jetbrains/pycharm/helpers/pydev/pydevd.py", line 1596, in <module>
    globals = debugger.run(setup['file'], None, None, is_module)

  File "/opt/jetbrains/pycharm/helpers/pydev/pydevd.py", line 974, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script

  File "ws.py", line 53, in <module>
    GlobalVars.wrap.login(username, password)

  File "ChatExchange/chatexchange/client.py", line 138, in login
    self._br.login_se_openid(email, password)

  File "ChatExchange/chatexchange/browser.py", line 154, in login_se_openid
    "failed to get `usr` cookie from Stack Exchange OpenID")

Normally however this stack trace is absorbed by a try/except block which was used for capturing exceptions, but of course this doesn't work right so blah.

ByteCommander commented 7 years ago

I have to admit I have no idea about this. Probably your best chance is to wait for someone like @Manishearth or @ProgramFOX to look at your issue...

teward commented 7 years ago

Ultimately stems from an issue with credentials and a not-so-understandable error message.