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 4 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 😄

@andersonrocha0
Copy link
Author

@amad @robertoles @benjamin-tang-pusher @benw-pusher I'm tagging you because you were the last committers on this project. Do you have any intention to finish this PR?

Thanks for any help you can give me.

:)

pusher/util.py Outdated Show resolved Hide resolved
pusher/util.py Outdated Show resolved Hide resolved
pusher/util.py Show resolved Hide resolved
pusher_tests/test_util.py Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
pusher/authentication_client.py Show resolved Hide resolved
pusher/pusher_client.py Outdated Show resolved Hide resolved
@evgeniibreikin
Copy link

@andersonrocha0 Hey! Pusher team is here, we back!
Thanks a lot for your PR! I've added e few notes around your PR

@evgeniibreikin evgeniibreikin added dependencies Pull requests that update a dependency file feature New feature support labels Dec 19, 2024
@andersonrocha0
Copy link
Author

@evgeniibreikin I reviewed your comments and fixed some ones of them. Could you please double-check?

Thx.

@andersonrocha0 andersonrocha0 force-pushed the add_user_authentication_and_send_message branch from ff5e8eb to 6242ea7 Compare December 27, 2024 15:07
pusher/util.py Outdated Show resolved Hide resolved
pusher/util.py Outdated Show resolved Hide resolved
pusher_tests/test_util.py Outdated Show resolved Hide resolved
pusher_tests/test_util.py Outdated Show resolved Hide resolved
@evgeniibreikin
Copy link

evgeniibreikin commented Jan 2, 2025

@evgeniibreikin I reviewed your comments and fixed some ones of them. Could you please double-check?

Thx.

@andersonrocha0

Thanks for changes! Last thing I wanna ask you is in my changes request. The reason is: channel name starting with # is incorrect, and the only correct option when you send it to user with prefix #server-to-user-
Imao, it is not clear in pusher.com documentation, will fix it later

@gvso
Copy link

gvso commented Jan 8, 2025

@evgeniibreikin I reviewed your comments and fixed some ones of them. Could you please double-check?
Thx.

@andersonrocha0

Thanks for changes! Last thing I wanna ask you is in my changes request. The reason is: channel name starting with # is incorrect, and the only correct option when you send it to user with prefix #server-to-user- Imao, it is not clear in pusher.com documentation, will fix it later

I'd like this to be merged and release. Is removing the expectation of the '#' as a prefix the only thing missing?

@evgeniibreikin
Copy link

@evgeniibreikin I reviewed your comments and fixed some ones of them. Could you please double-check?
Thx.

@andersonrocha0
Thanks for changes! Last thing I wanna ask you is in my changes request. The reason is: channel name starting with # is incorrect, and the only correct option when you send it to user with prefix #server-to-user- Imao, it is not clear in pusher.com documentation, will fix it later

I'd like this to be merged and release. Is removing the expectation of the '#' as a prefix the only thing missing?

Yes, everything from changes request. Btw, you can clone this branch locally and use it instead of pip package version

@andersonrocha0 andersonrocha0 force-pushed the add_user_authentication_and_send_message branch from 1ac47dc to 2b8fcc2 Compare January 18, 2025 14:12
@andersonrocha0
Copy link
Author

@evgeniibreikin and @gvso every suggestion was applied and squashed into one commit. Please, double check it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file feature New feature support release-minor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Drop support for python 2.7
6 participants