44# Script to create a JWT (JSON Web Token) signed with a private RSA key.
55#
66# Usage:
7- # ./create-app-jwt.sh <client_id > <private_key_file>
7+ # ./create-app-jwt.sh <app_id_or_client_id > <private_key_file>
88#
99# Arguments:
10- # <client_id> The client ID to use as the JWT issuer (iss).
11- # <private_key_file> Path to the PEM-encoded RSA private key file.
10+ # <app_id_or_client_id> The GitHub App ID (integer) or Client ID (Iv1.xxx)
11+ # to use as the JWT issuer (iss). Both work.
12+ # <private_key_file> Path to the PEM-encoded RSA private key file.
1213#
1314# Example:
14- # ./create-app-jwt.sh my-client-id /path/to/private-key.pem
15+ # ./create-app-jwt.sh 123456 /path/to/private-key.pem
16+ # ./create-app-jwt.sh Iv1.abc123def456 /path/to/private-key.pem
1517#
1618# The script outputs the generated JWT to stdout.
1719# -----------------------------------------------------------------------------
@@ -20,11 +22,11 @@ set -o pipefail
2022# Input validation for required parameters
2123if [ -z " $1 " ] || [ -z " $2 " ]; then
2224 echo " Error: Missing required parameters." >&2
23- echo " Usage: $0 <client_id > <path_to_private_key_pem>" >&2
25+ echo " Usage: $0 <app_id_or_client_id > <path_to_private_key_pem>" >&2
2426 exit 1
2527fi
2628
27- client_id =$1 # Client ID as first argument
29+ app_id_or_client_id =$1 # App ID (integer) or Client ID (Iv1.xxx) - both work
2830
2931# Check if the private key file exists and is readable
3032if [ ! -f " $2 " ] || [ ! -r " $2 " ]; then
@@ -49,7 +51,7 @@ header=$( echo -n "${header_json}" | b64enc )
4951payload_json=" {
5052 \" iat\" :${iat} ,
5153 \" exp\" :${exp} ,
52- \" iss\" :\" ${client_id } \"
54+ \" iss\" :\" ${app_id_or_client_id } \"
5355}"
5456# Payload encode
5557payload=$( echo -n " ${payload_json} " | b64enc )
0 commit comments