With the current version of the Matrix protocol, getting an access_token programmatically works slightly different:
To find out the endpoint, e.g., for matrix.org, you need to check a .well-known
file for the API URL (Documentation): https://matrix.org/.well-known/matrix/client
:
$ curl https://matrix.org/.well-known/matrix/client
{
"m.homeserver": {
"base_url": "https://matrix-client.matrix.org"
},
"m.identity_server": {
"base_url": "https://vector.im"
}
}
Afterwards, the homeserver base url can be used for the curl call (See Documentation for the /login endpoint):
$ curl '{"type":"m.login.password", "user":"'$username'", "password":"'$password'"} \
"https://$base_url/_matrix/client/v3/login"
{
"user_id":"@username:matrix.org",
"access_token":"token",
"home_server":"matrix.org",
"device_id":"ID",
"well_known": {
"m.homeserver": {
"base_url":"https://matrix-client.matrix.org/"
}
}
}