Matrix Token (m.login.token) support added
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.
- [x] There is no commented out code in this PR.
- [x] No lint errors (use
flake8) - [x] 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"
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
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
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
🚨 Try these New Features:
- Flaky Tests Detection - Detect and resolve failed and flaky tests
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.
looks like it's going for a registration token instead of an access token.
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?
Tested and wasn't able to get it working. Would provide logs but nothing printed in terminal.
Try adding -vvv to the CLI command
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"}
Oops I didn't even see this PR. This is also a copy of https://github.com/caronc/apprise/pull/1236
See #1236