File size: 1,641 Bytes
6a725a4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""
Helper script for retrieving a Google Drive refresh token.

Run it once, finish the OAuth flow, then copy the printed token into
REFRESH_TOKEN inside google_drive_sync.py.

If you hit an invalid_client error, consider switching to the Service
Account approach, which is more reliable.
"""

from google_drive_sync import get_refresh_token

if __name__ == "__main__":
    print("="*60)
    print("Google Drive Refresh Token Helper")
    print("="*60)
    print("\n⚠️  If you see 'invalid_client', the OAuth client is misconfigured.")
    print("   Use the Service Account method instead (no OAuth required).")
    print("   See google_drive_setup_guide.md for the full walkthrough.\n")
    print("A browser window will open so you can complete Google sign-in...\n")
    
    refresh_token = get_refresh_token()
    
    if refresh_token:
        print("\n✅ Success! Copy the refresh_token above into google_drive_sync.py.")
    else:
        print("\n" + "="*60)
        print("❌ Failed to get refresh_token")
        print("="*60)
        print("\nPossible fixes:")
        print("1. Use a Service Account (recommended):")
        print("   - See option B in google_drive_setup_guide.md")
        print("   - Create a Service Account and download the JSON key")
        print("   - Set SERVICE_ACCOUNT_FILE inside google_drive_sync.py")
        print("\n2. Create a new OAuth client:")
        print("   - Visit https://console.cloud.google.com/")
        print("   - Create a new OAuth 2.0 client ID")
        print("   - Update CLIENT_ID and CLIENT_SECRET in google_drive_sync.py")
        print("="*60)