Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tutorial - Implementing Token Authentication Errors #119

Open
digitalchild opened this issue Jan 19, 2024 · 0 comments
Open

Tutorial - Implementing Token Authentication Errors #119

digitalchild opened this issue Jan 19, 2024 · 0 comments

Comments

@digitalchild
Copy link

Following along with this https://ably.com/tutorials/token-authentication and the code doesn't work. I assumed it was something I had copied incorrectly. Got the source from here and tried to run it, same errors.

When entering the username and hitting enter, server.py produces a 500 error and client also produces an error.

This is because the authentication needs to be awaited for the token to be returned in time to return to the client.

Server error:

Traceback (most recent call last): File "/Projects/ably/tutorials/venv/lib/python3.10/site-packages/web/application.py", line 280, in process return self.handle() File "/Projects/ably/tutorials/venv/lib/python3.10/site-packages/web/application.py", line 271, in handle return self._delegate(fn, self.fvars, args) File "/Projects/ably/tutorials/venv/lib/python3.10/site-packages/web/application.py", line 502, in _delegate return handle_class(f) File "/Projects/ably/tutorials/venv/lib/python3.10/site-packages/web/application.py", line 495, in handle_class return tocall(*args) File "/Projects/ably/tutorials/server.py", line 34, in GET return json.dumps(client.auth.create_token_request(token_params).to_dict()) AttributeError: 'coroutine' object has no attribute 'to_dict'

Client error:

09:38:33.437 Ably: Auth.requestToken(): token request signing call returned error; err = [t: Malformed response body from server: Unexpected token '<', "<!DOCTYPE "... is not valid JSON; statusCode=400] r @ ably.min-1.js:24

Environment details:

OSX 14.2.1 
Python 3.10.3
Pip List: 

Package           Version
----------------- ----------
ably              2.0.3
anyio             4.2.0
certifi           2023.11.17
cheroot           10.0.0
exceptiongroup    1.2.0
h11               0.14.0
h2                4.1.0
hpack             4.0.0
httpcore          0.17.3
httpx             0.24.1
hyperframe        6.0.1
idna              3.6
jaraco.functools  4.0.0
methoddispatch    3.0.2
more-itertools    10.2.0
msgpack           1.0.7
pip               22.0.4
pyee              11.1.0
setuptools        58.1.0
sniffio           1.3.0
typing_extensions 4.9.0
web.py            0.62
websockets        10.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant