File size: 4,397 Bytes
33d3592
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/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()