5

In the Matrix instant messaging protocol, when using the reference implementation of the Matrix server (called synapse), there is an admin API with functions like resetting a password for a user etc..

Accessing this requires an access_token "API key" of a server admin user.

How do I get one?

8

Solution to find your access token:

  1. Log in to the account you want to get the access token for. Click on the name in the top left corner, then "Settings".
  2. Click the "Help & About" tab (left side of the dialog).
  3. Scroll to the bottom and click on <click to reveal> part of Access Token.
  4. Copy your access token to a safe place.
1
  • In Element, Help & About was all the way at the bottom of settings. And then Access Token was at the bottom of the Help & About pane, under the Advanced heading.
    – Coburn
    Aug 26 at 5:30
3

These access_token API keys were listed in the Riot web application until not too long ago, somewhere under the account settings. In the newest version, I could no longer find them there.

So instead, I use a technique I found here, which is basically a login procedure done with curl. The server's answer will contain the access_token.

  1. Find out the Matrix user ID and password of a server admin user. The username has to be in the fully qualified form, for example @user:example.com.

  2. Execute the following command on a Linux-based system that has curl installed. Of course, supply the address of you Matrix server for example.com, and also your Matrix user ID and password.

    curl -XPOST \
      -d '{"type":"m.login.password", "user":"<userid>", "password":"<password>"}' \
      "https://example.com:8448/_matrix/client/r0/login"
    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.