matrix-org / matrix-org/matrix-python-sdk

Registration fails "An access token should not be provided on requests to /register"

Open
#323 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
266
Forks
118
PR merge metrics
No merged PRs in 30d

Description

Describe the bug
Trying to register a new account fails with "An access token should not be provided on requests to /register (except if type is m.login.application_service)", although no token was ever set.

To Reproduce

from matrix_client.client import MatrixClient
matrix = MatrixClient("${homeserverUrl}")
matrix.register_with_password(username="alice", password="foobar")

Expected behavior
Login works fine

Actual behavior

Client side:

Traceback (most recent call last):
  File "test.py", line 3, in <module>
    matrix.register_with_password(username="alice", password="foobar")
  File "/lib/python3.9/site-packages/matrix_client/client.py", line 203, in register_with_password
    response = self.api.register(
  File "/lib/python3.9/site-packages/matrix_client/api.py", line 160, in register
    return self._send(
  File "/lib/python3.9/site-packages/matrix_client/api.py", line 748, in _send
    raise MatrixRequestError(
matrix_client.errors.MatrixRequestError: 400: {"errcode":"M_UNKNOWN","error":"An access token should not be provided on requests to /register (except if type is m.login.application_service)"}

Server side:

[  104.741510] synapse[1153]: synapse.http.server: [POST-1] <SynapseRequest at 0x7fc64ed887f0 method='POST' uri='/_matrix/client/r0/register?kind=user' clientproto='HTTP/1.1' site='8448'> SynapseError: 400 - An access token should not be provided on requests to /register (except if type is m.login.application_service)
[  104.753403] synapse[1153]: synapse.access.http.8448: [POST-1] ::ffff:192.168.1.2 - 8448 - {None} Processed request: 0.010sec/-0.000sec (0.001sec, 0.001sec) (0.000sec/0.000sec/0) 140B 400 "POST /_matrix/client/r0/register?kind=user HTTP/1.1" "matrix-python-sdk/0.4.0" [0 dbevts]

Additional context
This is probably a regression in 0.4.0 related to the addition of use_authorization_header. Also the tests currently only test the creation of guest accounts.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in matrix_client/api.py at the _send and register calls shown in the traceback, then review matrix_client/client.py's register_with_password path and the existing guest-account tests. Reproduce the registration request and confirm it succeeds without an access token; add coverage for password registration alongside the current tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, authentication
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.