syncmaster8 / check_credentials.py
aseelflihan's picture
Initial commit without node_modules
33d3592
#!/usr/bin/env python3
# check_credentials.py - ุฃุฏุงุฉ ูุญุต ู…ู„ู ุจูŠุงู†ุงุช ุงู„ุงุนุชู…ุงุฏ
import os
import json
def check_credentials():
"""ูุญุต ู…ู„ู credentials.json ูˆุงู„ุชุฃูƒุฏ ู…ู† ุตุญุชู‡"""
print("๐Ÿ” ูุญุต ู…ู„ู ุจูŠุงู†ุงุช ุงู„ุงุนุชู…ุงุฏ...")
print("=" * 50)
# ูุญุต ูˆุฌูˆุฏ ุงู„ู…ู„ู
if not os.path.exists('credentials.json'):
print("โŒ ู…ู„ู credentials.json ุบูŠุฑ ู…ูˆุฌูˆุฏ!")
print("๐Ÿ’ก ุชุฃูƒุฏ ู…ู† ูˆุถุน ุงู„ู…ู„ู ููŠ ู†ูุณ ู…ุฌู„ุฏ app.py")
return False
print("โœ… ู…ู„ู credentials.json ู…ูˆุฌูˆุฏ")
# ูุญุต ู…ุญุชูˆู‰ ุงู„ู…ู„ู
try:
with open('credentials.json', 'r') as f:
creds = json.load(f)
print("โœ… ุงู„ู…ู„ู ูŠุญุชูˆูŠ ุนู„ู‰ JSON ุตุญูŠุญ")
# ูุญุต ุงู„ุจู†ูŠุฉ
if 'installed' not in creds:
print("โŒ ุงู„ู…ู„ู ู„ุง ูŠุญุชูˆูŠ ุนู„ู‰ ู‚ุณู… 'installed'")
return False
installed = creds['installed']
# ูุญุต ุงู„ุญู‚ูˆู„ ุงู„ู…ุทู„ูˆุจุฉ
required_fields = ['client_id', 'client_secret', 'auth_uri', 'token_uri']
missing_fields = []
for field in required_fields:
if field not in installed:
missing_fields.append(field)
if missing_fields:
print(f"โŒ ุงู„ุญู‚ูˆู„ ุงู„ู…ูู‚ูˆุฏุฉ: {', '.join(missing_fields)}")
return False
# ูุญุต ุฅุฐุง ูƒุงู†ุช ุงู„ุจูŠุงู†ุงุช ูˆู‡ู…ูŠุฉ
client_id = installed.get('client_id', '')
client_secret = installed.get('client_secret', '')
if client_id.startswith('YOUR_CLIENT_ID'):
print("โŒ client_id ู„ุง ูŠุฒุงู„ ูŠุญุชูˆูŠ ุนู„ู‰ ุงู„ู‚ูŠู…ุฉ ุงู„ุงูุชุฑุงุถูŠุฉ!")
print("๐Ÿ’ก ูŠุฌุจ ุงุณุชุจุฏุงู„ ุงู„ู…ู„ู ุจู…ู„ู ุญู‚ูŠู‚ูŠ ู…ู† Google Cloud Console")
return False
if client_secret.startswith('YOUR_CLIENT_SECRET'):
print("โŒ client_secret ู„ุง ูŠุฒุงู„ ูŠุญุชูˆูŠ ุนู„ู‰ ุงู„ู‚ูŠู…ุฉ ุงู„ุงูุชุฑุงุถูŠุฉ!")
print("๐Ÿ’ก ูŠุฌุจ ุงุณุชุจุฏุงู„ ุงู„ู…ู„ู ุจู…ู„ู ุญู‚ูŠู‚ูŠ ู…ู† Google Cloud Console")
return False
print("โœ… ุฌู…ูŠุน ุงู„ุญู‚ูˆู„ ุงู„ู…ุทู„ูˆุจุฉ ู…ูˆุฌูˆุฏุฉ")
print(f"โœ… Client ID: {client_id[:20]}...")
print(f"โœ… Project ID: {installed.get('project_id', 'ุบูŠุฑ ู…ุญุฏุฏ')}")
return True
except json.JSONDecodeError:
print("โŒ ุงู„ู…ู„ู ู„ุง ูŠุญุชูˆูŠ ุนู„ู‰ JSON ุตุญูŠุญ!")
return False
except Exception as e:
print(f"โŒ ุฎุทุฃ ููŠ ู‚ุฑุงุกุฉ ุงู„ู…ู„ู: {e}")
return False
def check_token():
"""ูุญุต ู…ู„ู token.json ุฅุฐุง ูƒุงู† ู…ูˆุฌูˆุฏุงู‹"""
print("\n๐Ÿ” ูุญุต ู…ู„ู ุงู„ู…ุตุงุฏู‚ุฉ...")
print("=" * 50)
if os.path.exists('token.json'):
print("โœ… ู…ู„ู token.json ู…ูˆุฌูˆุฏ")
try:
with open('token.json', 'r') as f:
token = json.load(f)
if 'token' in token:
print("โœ… ูŠุญุชูˆูŠ ุนู„ู‰ ุฑู…ุฒ ู…ุตุงุฏู‚ุฉ")
if 'refresh_token' in token:
print("โœ… ูŠุญุชูˆูŠ ุนู„ู‰ ุฑู…ุฒ ุงู„ุชุญุฏูŠุซ")
if 'expiry' in token:
print(f"โฐ ุชุงุฑูŠุฎ ุงู†ุชู‡ุงุก ุงู„ุตู„ุงุญูŠุฉ: {token['expiry']}")
except Exception as e:
print(f"โš ๏ธ ู…ุดูƒู„ุฉ ููŠ ู…ู„ู token.json: {e}")
print("๐Ÿ’ก ูŠู…ูƒู†ูƒ ุญุฐู ุงู„ู…ู„ู ูˆุฅุนุงุฏุฉ ุงู„ู…ุตุงุฏู‚ุฉ")
else:
print("โ„น๏ธ ู…ู„ู token.json ุบูŠุฑ ู…ูˆุฌูˆุฏ (ุทุจูŠุนูŠ ููŠ ุฃูˆู„ ุงุณุชุฎุฏุงู…)")
def main():
print("๐Ÿš€ ุฃุฏุงุฉ ูุญุต ุจูŠุงู†ุงุช ุงู„ุงุนุชู…ุงุฏ ู„ู€ Google Docs")
print("=" * 60)
creds_ok = check_credentials()
check_token()
print("\n" + "=" * 60)
if creds_ok:
print("๐ŸŽ‰ ู…ู„ู ุจูŠุงู†ุงุช ุงู„ุงุนุชู…ุงุฏ ุตุญูŠุญ!")
print("๐Ÿ’ก ูŠู…ูƒู†ูƒ ุงู„ุขู† ุงุณุชุฎุฏุงู… ุฒุฑ ุงู„ุชุตุฏูŠุฑ")
else:
print("โŒ ูŠุฌุจ ุฅุตู„ุงุญ ู…ู„ู ุจูŠุงู†ุงุช ุงู„ุงุนุชู…ุงุฏ ุฃูˆู„ุงู‹")
print("๐Ÿ“‹ ุฑุงุฌุน ู…ู„ู GOOGLE_SETUP_SIMPLE.md ู„ู„ุญุตูˆู„ ุนู„ู‰ ุงู„ุชุนู„ูŠู…ุงุช")
if __name__ == "__main__":
main()