Uname:Linux antigravity-cli 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64

Base Dir : /var/www/moonbloom

User : wp-moonbloom


403WebShell
403Webshell
Server IP : 85.155.190.233  /  Your IP : 216.73.216.103
Web Server : nginx/1.24.0
System : Linux antigravity-cli 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64
User : wp-moonbloom ( 1001)
PHP Version : 8.3.6
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /proc/2398464/root/opt/Gemini_Swarm_Core/scripts/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/2398464/root/opt/Gemini_Swarm_Core/scripts/check_cli_token.py
import json
import httpx
import subprocess
import os

def test():
    # 1. Run agy to force token refresh on disk
    print("Running agy CLI to refresh token on disk...")
    env = {**os.environ, "HOME": "/root", "GEMINI_CLI_TRUST_WORKSPACE": "true"}
    res = subprocess.run(
        ["agy", "-p", "hi"],
        env=env,
        capture_output=True,
        text=True
    )
    print("CLI Output:", res.stdout.strip())
    
    # 2. Read oauth_creds.json
    oauth_path = "/root/.gemini/oauth_creds.json"
    if not os.path.exists(oauth_path):
        oauth_path = "/opt/Gemini_Swarm_Core/.gemini/oauth_creds.json"
    
    print(f"Reading oauth_creds.json from {oauth_path}...")
    with open(oauth_path) as f:
        data = json.load(f)
    
    raw_token = data.get("access_token")
    print("New access token (first 10 chars):", raw_token[:10] + "...")
    
    # 3. Query tokeninfo
    print("Querying tokeninfo for CLI-refreshed token...")
    r = httpx.get(f"https://www.googleapis.com/oauth2/v1/tokeninfo?access_token={raw_token}")
    print("Tokeninfo status:", r.status_code)
    if r.status_code == 200:
        print("Tokeninfo:", json.dumps(r.json(), indent=2))
    else:
        print("Tokeninfo error:", r.text)
        
    # 4. Try REST call with this token
    print("Trying direct REST call to Gemini API with CLI-refreshed token...")
    url = "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent"
    headers = {
        "Authorization": f"Bearer {raw_token}",
        "Content-Type": "application/json"
    }
    payload = {
        "contents": [{"parts": [{"text": "Hello! Answer in one short sentence in Russian."}]}]
    }
    r2 = httpx.post(url, json=payload, headers=headers)
    print("REST status:", r2.status_code)
    if r2.status_code == 200:
        print("REST response:", r2.json()["candidates"][0]["content"]["parts"][0]["text"])
    else:
        print("REST error:", r2.text)

if __name__ == "__main__":
    test()

Youez - 2016 - github.com/yon3zu
LinuXploit