15 lines
424 B
Bash
Executable File
15 lines
424 B
Bash
Executable File
#!/bin/bash
|
|
if [ $# -ne 3 ]; then
|
|
echo "Usage: $0 <username> <password> <matrix server domain>"
|
|
exit 1
|
|
fi
|
|
|
|
access_token=$(curl -s -XPOST -d '{"type":"m.login.password", "user":"'"$1"'", "password":"'"$2"'"}' "https://$3/_matrix/client/r0/login" | jq -r '.access_token')
|
|
|
|
if [ -z "$access_token" ]; then
|
|
echo "Failed to retrieve access token. Please check your username and password."
|
|
exit 1
|
|
fi
|
|
|
|
echo "$access_token"
|