-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformat_credentials.py
More file actions
36 lines (30 loc) · 1.21 KB
/
Copy pathformat_credentials.py
File metadata and controls
36 lines (30 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""Helper script to format credentials.json for .env file."""
import json
print("Credentials Formatter for .env")
print("=" * 50)
print()
print("This script will read your credentials.json file and")
print("format it properly for the GOOGLE_CREDENTIALS environment variable.")
print()
try:
# Read the credentials file
with open('credentials.json', 'r') as f:
credentials = json.load(f)
# Convert to a single-line JSON string
credentials_str = json.dumps(credentials, separators=(',', ':'))
print("✅ Successfully formatted credentials!")
print()
print("Add this line to your .env file:")
print("-" * 50)
print(f"GOOGLE_CREDENTIALS={credentials_str}")
print("-" * 50)
print()
print("Note: Copy the entire line above (including GOOGLE_CREDENTIALS=)")
print(" and paste it into your .env file on a single line.")
except FileNotFoundError:
print("❌ Error: credentials.json file not found")
print(" Please make sure credentials.json exists in the current directory")
except json.JSONDecodeError as e:
print(f"❌ Error: Invalid JSON in credentials.json: {e}")
except Exception as e:
print(f"❌ Error: {e}")