#!/usr/bin/env python3
"""Generate Google Ads API refresh token via OAuth flow."""

from google_auth_oauthlib.flow import InstalledAppFlow

CLIENT_CONFIG = {
    "installed": {
        "client_id": "276650601999-468ib8q6bfoh5mkhbo62ljive1itdemk.apps.googleusercontent.com",
        "client_secret": "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",
        "auth_uri": "https://accounts.google.com/o/oauth2/auth",
        "token_uri": "https://oauth2.googleapis.com/token",
        "redirect_uris": ["http://localhost"]
    }
}

SCOPES = ['https://www.googleapis.com/auth/adwords']

def main():
    flow = InstalledAppFlow.from_client_config(CLIENT_CONFIG, scopes=SCOPES)
    
    # This opens a browser window for authorization
    credentials = flow.run_local_server(port=8080)
    
    print("\n" + "="*50)
    print("SUCCESS! Here's your refresh token:")
    print("="*50)
    print(f"\n{credentials.refresh_token}\n")
    print("="*50)
    print("Copy this token and send it to me!")
    print("="*50)

if __name__ == "__main__":
    main()
