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

Matrix Token (m.login.token) support added #1203

Closed
wants to merge 1 commit into from

Conversation

caronc
Copy link
Owner

@caronc caronc commented Sep 14, 2024

Description:

Related issue (if applicable): #895

The URLs now trigger reference to the Matrix Token based Authentication (m.login.token):

  • {schema}://{token}@{host}/{targets}
  • {schema}://{token}@{host}:{port}/{targets}

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • No lint errors (use flake8)
  • 100% test coverage

Testing

Anyone can help test this source code as follows:

# Create a virtual environment to work in as follows:
python3 -m venv apprise

# Change into our new directory
cd apprise

# Activate our virtual environment
source bin/activate

# Install the branch
pip install git+https://github.com/caronc/apprise.git@895-matrix-token-support

# Test out the changes with the following command:
apprise -t "Test Title" -b "Test Message" \
  "matrixs://token@host/#general"

Copy link

codecov bot commented Sep 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.29%. Comparing base (f37dfbf) to head (05b23fd).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1203      +/-   ##
==========================================
- Coverage   99.36%   99.29%   -0.08%     
==========================================
  Files         147      147              
  Lines       20555    20560       +5     
  Branches     3663     3665       +2     
==========================================
- Hits        20425    20415      -10     
- Misses        121      135      +14     
- Partials        9       10       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@caronc caronc changed the title m.login.token support for Matrix Matrix Token (m.login.token) support added Sep 14, 2024
@caronc caronc linked an issue Sep 14, 2024 that may be closed by this pull request
@ClemontX
Copy link

ClemontX commented Sep 26, 2024

unfortunately i can't say it's working:

❯    apprise -vv -t "Test Title" -b "Test Message" \
  'matrixs://<token>@<hostname>/!<channel-id>'
2024-09-26 09:50:12,914 - WARNING - Failed to handshake with Matrix server: Unauthorized - Invalid Token., error=403.
2024-09-26 09:50:13,109 - WARNING - Failed to handshake with Matrix server: Unauthorized - Invalid Token., error=403.

@ClemontX
Copy link

image

@ClemontX
Copy link

looks like it's going for a registration token instead of an access token.

@caronc
Copy link
Owner Author

caronc commented Sep 26, 2024

It almost looks like m.login.token was dropped from the specs entirely (see here).

What happens if you add ? version=2 to the Apprise URL to leverage the legacy Matrix API?

@natoleet
Copy link

Tested and wasn't able to get it working.
Would provide logs but nothing printed in terminal.

@caronc
Copy link
Owner Author

caronc commented Oct 25, 2024

Try adding -vvv to the CLI command

@natoleet
Copy link

natoleet commented Nov 2, 2024

DEBUG - Notification Plugin 109(s) and 155 Schema(s) loaded in 0.1062s
DEBUG - Loaded Matrix URL: matrixs://[email protected]/%23alerts?image=no&mode=off&version=3&msgtype=text&format=text&overflow=upstream
DEBUG - Matrix POST URL: https://matrix.DOMAINREDACTED.com/_matrix/client/v3/login (cert_verify=True)
DEBUG - Matrix Payload: {'type': 'm.login.token', 'token': 'TOKENREDACTED'}
DEBUG - Matrix Response: code=403, b'{"errcode":"M_FORBIDDEN","error":"Invalid login token"}'
WARNING - Failed to handshake with Matrix server: Unauthorized - Invalid Token., error=403.
DEBUG - Response Details:
b'{"errcode":"M_FORBIDDEN","error":"Invalid login token"}'
DEBUG - Matrix POST URL: https://matrix.DOMAINREDACTED.com/_matrix/client/v3/register (cert_verify=True)
DEBUG - Matrix Payload: {'kind': 'user', 'auth': {'type': 'm.login.dummy'}, 'password': 'TOKENREDACTED'}
DEBUG - Matrix Response: code=400, b'{"errcode":"M_UNKNOWN","error":"Invalid username"}'
WARNING - Failed to handshake with Matrix server: Bad Request - Unsupported Parameters., error=400.
DEBUG - Response Details:
b'{"errcode":"M_UNKNOWN","error":"Invalid username"}

@voc0der
Copy link
Contributor

voc0der commented Nov 19, 2024

Oops I didn't even see this PR. This is also a copy of #1236

@caronc
Copy link
Owner Author

caronc commented Nov 22, 2024

See #1236

@caronc caronc closed this Nov 22, 2024
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.

Matrix: Logging-in with an access_token
4 participants