Skip to content

Instantly share code, notes, and snippets.

@rgarlik
Last active March 21, 2023 19:59
Show Gist options
  • Save rgarlik/b128d3595f4f5907cfccd30f34a72da5 to your computer and use it in GitHub Desktop.
Save rgarlik/b128d3595f4f5907cfccd30f34a72da5 to your computer and use it in GitHub Desktop.
A script to obtain a Firebase JWT key for auth testing purposes.
#!/bin/bash
# Example usage:
# ./login.sh --email <email> --password <password> --apikey <api_key>
usage() {
echo "Usage: $0 --email <email> --password <password> --apikey <api_key>"
}
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
--email)
email="$2"
shift # past argument
shift # past value
;;
--password)
password="$2"
shift # past argument
shift # past value
;;
--apikey)
api_key="$2"
shift # past argument
shift # past value
;;
*) # unknown option
usage
exit 1
;;
esac
done
if [ -z "$email" ] || [ -z "$password" ] || [ -z "$api_key" ]; then
usage
exit 1
fi
curl "https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword?key=$api_key" \
-H 'Content-Type: application/json' \
--data-binary "{\"email\":\"$email\",\"password\":\"$password\",\"returnSecureToken\":true}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment