- CLAUDE.md with API reference, auth setup, and workspace details - scripts/fabric-api.sh: helper functions for Fabric REST API - scripts/refresh-token.sh: token refresh and .env writer - .gitignore: protect .env and .omc/ Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
33 lines
1.1 KiB
Bash
Executable file
33 lines
1.1 KiB
Bash
Executable file
#!/bin/bash
|
|
# Refresh Fabric API token and write it to .env
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
|
ENV_FILE="$PROJECT_DIR/.env"
|
|
|
|
echo "Refreshing Microsoft Fabric API token..."
|
|
|
|
TOKEN=$(az account get-access-token --resource "https://api.fabric.microsoft.com" --query accessToken -o tsv)
|
|
TENANT_ID=$(az account show --query tenantId -o tsv)
|
|
ACCOUNT_NAME=$(az account show --query user.name -o tsv)
|
|
SUBSCRIPTION=$(az account show --query name -o tsv)
|
|
EXPIRES=$(az account get-access-token --resource "https://api.fabric.microsoft.com" --query expiresOn -o tsv)
|
|
|
|
cat > "$ENV_FILE" <<EOF
|
|
# Microsoft Fabric API Configuration
|
|
# Auto-generated by refresh-token.sh - DO NOT COMMIT
|
|
# Token expires: $EXPIRES
|
|
|
|
FABRIC_TOKEN=$TOKEN
|
|
FABRIC_TENANT_ID=$TENANT_ID
|
|
FABRIC_ACCOUNT=$ACCOUNT_NAME
|
|
FABRIC_SUBSCRIPTION=$SUBSCRIPTION
|
|
FABRIC_API_BASE=https://api.fabric.microsoft.com/v1
|
|
EOF
|
|
|
|
echo "Token written to .env"
|
|
echo " Tenant: $TENANT_ID"
|
|
echo " Account: $ACCOUNT_NAME"
|
|
echo " Subscription: $SUBSCRIPTION"
|
|
echo " Expires: $EXPIRES"
|