#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
# shellcheck source=../lib/common.sh
source "${ROOT}/lib/common.sh"

# Returns authorization URL; complete flow in browser at that URL.
PROVIDER="${OAUTH_PROVIDER:-github}"
CALLBACK="${CALLBACK_URL:-http://localhost:3000/api/auth/callback/${PROVIDER}}"

curl_post_json "/sign-in/social" \
  "$(printf '%s' "{\"provider\":\"${PROVIDER}\",\"callbackURL\":\"${CALLBACK}\"}")" | pretty
