Last active 1705433084

Matrix access token

Jarno Rankinen revised this gist 1673520723. Go to revision

1 file changed, 10 insertions, 4 deletions

get_token.sh

@@ -2,9 +2,15 @@
2 2
3 3 # curl -XPOST -d '{"type": "m.login.password", "identifier": {"user": "botusername", "type": "m.id.user"}, "password": "passwordforuser"}' "https://home.server/_matrix/client/r0/login"
4 4
5 - USER=
6 - PASSWORD=
7 - HOMESERVER='https://'
5 + USER="$1"
6 + PASSWORD="$2"
7 + HOMESERVER="$3"
8 +
9 + if [[ -z "$1" ]] || [[ -z "$2" ]] || [[ -z "$3" ]]; then
10 + echo "Usage: $0 USERNAME PASSWORD HOMESERVER_URL"
11 + exit 1
12 + fi
8 13
9 14 STR="{\"type\": \"m.login.password\", \"identifier\": {\"user\": \"$USER\", \"type\": \"m.id.user\"}, \"password\": \"$PASSWORD\"}
10 - curl -XPOST -d "$STR" "$HOMESERVER/_matrix/client/r0/login"
15 + curl -XPOST -d "$STR" "$HOMESERVER/_matrix/client/r0/login" | sed 's/,/,\n/g'
16 + printf "\n"

Jarno Rankinen revised this gist 1664515558. Go to revision

1 file changed, 10 insertions

get_token.sh(file created)

@@ -0,0 +1,10 @@
1 + #!/bin/bash
2 +
3 + # curl -XPOST -d '{"type": "m.login.password", "identifier": {"user": "botusername", "type": "m.id.user"}, "password": "passwordforuser"}' "https://home.server/_matrix/client/r0/login"
4 +
5 + USER=
6 + PASSWORD=
7 + HOMESERVER='https://'
8 +
9 + STR="{\"type\": \"m.login.password\", \"identifier\": {\"user\": \"$USER\", \"type\": \"m.id.user\"}, \"password\": \"$PASSWORD\"}
10 + curl -XPOST -d "$STR" "$HOMESERVER/_matrix/client/r0/login"
Newer Older