setup-demo-account.sh

#!/bin/sh
AT_ID=3904412097-0551
GREP=/usr/bin/grep
CUT=/usr/bin/cut

# Constant auth code to try
AUTH_CODE=111111

while true; do
  # Create a new challenge
  CREATE_CHALLENGE_OUTPUT=$(./create-challenge.sh 'PUT' "/api/attendees/$AT_ID/auth")
  CHALLENGE_ID=$(echo "$CREATE_CHALLENGE_OUTPUT" | $GREP -o '"id":"[^"]*' | $CUT -d '"' -f 4)
  PATH=$(echo "$CREATE_CHALLENGE_OUTPUT" | $GREP -o '"path":"[^"]*' | $CUT -d '"' -f 4)

  # Perform authentication attempt with the retrieved challenge ID and constant auth code
  AUTH_OUTPUT=$(./verb-with-auth-code.sh $PATH $CHALLENGE_ID $AUTH_CODE)
  echo "Trying $AUTH_CODE for challenge $CHALLENGE_ID"

  # Check if the output contains JWT token
  if [[ "$AUTH_OUTPUT" != *"Bad Auth"* ]]; then
    echo "Authentication succeeded! Received JWT: $AUTH_OUTPUT"
    break
  else
    echo "Authentication failed, retrying..."
  fi
done