Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ReactPy websocket authentication has failed! #153

Answered by Archmonger
numpde asked this question in Problem
Discussion options

I'm using 'allauth' in my Django project. While loading a 'Hello world' component from a template (which does show up on the page), I get the following error. There are many moving parts, so please let me know what other details you might need.

ReactPy websocket authentication has failed!
Traceback (most recent call last):
 File "PATH/venv/lib/python3.11/site-packages/channels/auth.py", line 95, in login
 backend = backend or user.backend
 ^^^^^^^^^^^^
 File "PATH/venv/lib/python3.11/site-packages/django/utils/functional.py", line 268, in inner
 return func(_wrapped, *args)
 ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'User' object has no attribute 'backend'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
 File "PATH/venv/lib/python3.11/site-packages/reactpy_django/websocket/consumer.py", line 37, in connect
 await login(self.scope, user)
 File "PATH/venv/lib/python3.11/site-packages/asgiref/sync.py", line 479, in __call__
 ret: _R = await loop.run_in_executor(
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "/usr/lib/python3.11/concurrent/futures/thread.py", line 58, in run
 result = self.fn(*self.args, **self.kwargs)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "PATH/venv/lib/python3.11/site-packages/channels/db.py", line 13, in thread_handler
 return super().thread_handler(loop, *args, **kwargs)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "PATH/venv/lib/python3.11/site-packages/asgiref/sync.py", line 538, in thread_handler
 return func(*args, **kwargs)
 ^^^^^^^^^^^^^^^^^^^^^
 File "PATH/venv/lib/python3.11/site-packages/channels/auth.py", line 101, in login
 raise ValueError(
ValueError: You have multiple authentication backends configured and therefore must provide the `backend` argument or set the `backend` attribute on the user.
# In settings.py:
AUTHENTICATION_BACKENDS = [
 # Needed to login by username in Django admin, regardless of `allauth`
 'django.contrib.auth.backends.ModelBackend',
 # `allauth` specific authentication methods, such as login by e-mail
 'allauth.account.auth_backends.AuthenticationBackend',
]

Using:

reactpy==1.0.1
reactpy-django==3.1.0

You must be logged in to vote

Resolved via this PR, will be released as v3.2.0 shortly.

You will need to define REACTPY_AUTH_BACKEND assuming that...

  1. You are using AuthMiddlewareStack and...
  2. You are using Django's AUTHENTICATION_BACKENDS setting and...
  3. Your Django user model does not define a backend attribute

Replies: 2 comments 2 replies

Comment options

@Archmonger, perhaps related to #151?

You must be logged in to vote
1 reply
Comment options

Yup, same issue.

Comment options

Resolved via this PR, will be released as v3.2.0 shortly.

You will need to define REACTPY_AUTH_BACKEND assuming that...

  1. You are using AuthMiddlewareStack and...
  2. You are using Django's AUTHENTICATION_BACKENDS setting and...
  3. Your Django user model does not define a backend attribute
You must be logged in to vote
1 reply
Comment options

Affirmative. Thanks!

Answer selected by Archmonger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /