#!/bin/bash if [ $# -ne 3 ]; then echo "Usage: $0 " 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"