Last active
March 21, 2023 19:59
-
-
Save rgarlik/b128d3595f4f5907cfccd30f34a72da5 to your computer and use it in GitHub Desktop.
A script to obtain a Firebase JWT key for auth testing purposes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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