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

Add user authentication and the possibility to trigger/send a message… #207

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

andersonrocha0
Copy link

What does this PR do?

Add the authenticate_user method allowing clients to authenticate users.
Add the send_to_user_method allowing any backend to send messages to a specific user.

  • If you have changed dependencies, ensure both requirements.txt and setup.py have been updated

CHANGELOG

  • [ADDED] authenticate_user method
  • [ADDED] send_to_user method

@andersonrocha0 andersonrocha0 marked this pull request as ready for review June 14, 2023 13:34
@benjamin-tang-pusher benjamin-tang-pusher self-assigned this Aug 14, 2023
@benjamin-tang-pusher
Copy link
Contributor

benjamin-tang-pusher commented Aug 15, 2023

When I call
channels_client.send_to_user("123", "user-event", {"message": "hello worlds"})
I get this error (although the message goes through to my client)

File "/Users/benjamintang/development/python/channels/app.py", line 124, in send_to_user
channels_client.send_to_user("123", "user-event", {"message": "hello worlds"})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/benjamintang/development/python/channels/venv/lib/python3.11/site-packages/pusher/pusher.py", line 151, in send_to_user
return self._pusher_client.send_to_user(user_id, event_name, data)
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/benjamintang/development/python/channels/venv/lib/python3.11/site-packages/pusher/http.py", line 31, in __call__
return self.client.http.send_request(self.make_request(*args, **kwargs))
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/benjamintang/development/python/channels/venv/lib/python3.11/site-packages/pusher/requests.py", line 39, in send_request
        self.session = requests.Session()
 
 
    def send_request(self, request):
        resp = self.session.request(
            request.method,
            ^^^^^^^^^^^^^^
            request.url,
            headers=request.headers,
            data=request.body,
            timeout=self.client.timeout,
            **self.options)
AttributeError: 'dict' object has no attribute 'method'

Do you not get this too? It's odd, as the trigger() method should put POST as the argument, so I'm not sure where its going missing.

@andersonrocha0

@andersonrocha0 andersonrocha0 force-pushed the add_user_authentication_and_send_message branch from 5aaeaec to f09845c Compare August 17, 2023 15:46
@andersonrocha0
Copy link
Author

@benjamin-tang-pusher Yes, you are right.

I found the problem and fixed it.

The @request_method is unnecessary because the send_to_user is only a wrapper calling the trigger.

Now, the code is fixed and working.

Please let me know if you have any other problems.

:)

@benjamin-tang-pusher
Copy link
Contributor

Whoops, I forgot about that decorator. I gave it another test and it works now.

I will ask the team to review it.

benjamin-tang-pusher

This comment was marked as duplicate.

@benjamin-tang-pusher benjamin-tang-pusher removed their assignment Aug 18, 2023
@benjamin-tang-pusher benjamin-tang-pusher linked an issue Aug 18, 2023 that may be closed by this pull request
@andersonrocha0
Copy link
Author

@fbenevides do you have any news?

Thx.

@hugovk hugovk mentioned this pull request Oct 5, 2023
1 task
@amplicity
Copy link

+1, need this

@andersonrocha0
Copy link
Author

Any news here?

@alexanderlukens
Copy link

@fbenevides any updates on this PR? Would be super helpful to have 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Drop support for python 2.7
4 participants