Skip to content

feat: a one-time login that gives the bot a token without an expiry - #2

Merged
Xenolphthalein merged 2 commits into
mainfrom
feat/login-helper
Dec 1, 2026
Merged

Xenolphthalein merged 2 commits into
mainfrom
feat/login-helper

Conversation

@Xenolphthalein

Copy link
Copy Markdown
Contributor

The bot's token copied out of Element stopped working (401 M_UNKNOWN_TOKEN): matrix.org's logins go through MAS, and Element's session token is short-lived and renewed by Element itself.

MAS gives a legacy password login (m.login.password) that asks for no refresh token an access token without an expiry (crates/handlers/src/compat/login.rs: "If the client asked for a refreshable token, make it expire"). A test login on matrix.org confirmed it: no expires_in_ms, no refresh token, the requested device ID kept.

  • python -m matrix_space.login logs the bot in once as the device overpressure-github, refuses a token that expires (and ends its session), checks whose the token is, and prints it alone on standard output, to pipe into the secret: uv run python -m matrix_space.login | gh secret set MATRIX_ACCESS_TOKEN --env matrix --repo overpressure/matrix. Running it again replaces the session.
  • Api can log in without a token, and log out.
  • Tests against a fake server; the README's setup and the Space workflow's comment say how the token is made.

The workflows are unchanged: they read MATRIX_ACCESS_TOKEN as before.

… by a password login that asks for no refresh token, which MAS gives a token without an expiry; it refuses an expiring one and prints the token alone, to pipe into the secret
@Xenolphthalein
Xenolphthalein requested a review from a team as a code owner December 1, 2026 07:43
@Xenolphthalein
Xenolphthalein merged commit 8e1b3e2 into main Dec 1, 2026
5 checks passed
@Xenolphthalein
Xenolphthalein deleted the feat/login-helper branch December 1, 2026 07:46
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.

1 participant