-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify_api_key.py
More file actions
56 lines (48 loc) · 1.61 KB
/
verify_api_key.py
File metadata and controls
56 lines (48 loc) · 1.61 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""API 키 확인 스크립트"""
import os
from dotenv import load_dotenv
print("=" * 60)
print("API 키 확인")
print("=" * 60)
print()
# .env 파일 직접 읽기
env_path = ".env"
if os.path.exists(env_path):
print("✓ .env 파일 존재")
with open(env_path, 'r', encoding='utf-8') as f:
content = f.read()
print("\n.env 파일 내용:")
print("-" * 60)
for line in content.split('\n'):
if line.strip() and not line.strip().startswith('#'):
if 'GOOGLE_API_KEY' in line:
# API 키 마스킹
if '=' in line:
key_part = line.split('=')[1].strip()
if key_part:
masked = key_part[:10] + "..." + key_part[-4:] if len(key_part) > 14 else "***"
print(f"{line.split('=')[0]}={masked}")
else:
print(line)
else:
print(line)
else:
print(line)
print("-" * 60)
else:
print("✗ .env 파일이 없습니다!")
exit(1)
print()
# dotenv로 로드된 값 확인
load_dotenv()
loaded_key = os.getenv("GOOGLE_API_KEY")
if loaded_key:
masked_loaded = loaded_key[:10] + "..." + loaded_key[-4:] if len(loaded_key) > 14 else "***"
print(f"✓ dotenv로 로드된 API 키: {masked_loaded}")
print(f" 전체 길이: {len(loaded_key)} 문자")
else:
print("✗ dotenv로 API 키를 로드할 수 없습니다!")
print()
print("=" * 60)