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 :  /opt/Gemini_Swarm_Core/scripts/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/Gemini_Swarm_Core/scripts/test_direct_oauth.py
import json
import httpx
from google.oauth2.credentials import Credentials
from google.auth.transport.requests import Request

def test():
    oauth_path = "/opt/Gemini_Swarm_Core/.gemini/oauth_creds.json"
    try:
        with open(oauth_path) as f:
            creds_data = json.load(f)
    except Exception as e:
        print(f"Error loading oauth_creds.json: {e}")
        return

    creds = Credentials(
        token=creds_data.get("access_token"),
        refresh_token=creds_data.get("refresh_token"),
        token_uri="https://oauth2.googleapis.com/token",
        client_id="681255809395-oo8ft2oprdrnp9e3aqf6av3hmdib135j.apps.googleusercontent.com",
        client_secret="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",
        scopes=["https://www.googleapis.com/auth/cloud-platform"]
    )

    try:
        print("Refreshing credentials...")
        req = Request()
        creds.refresh(req)
        print("Refreshed successfully!")
    except Exception as e:
        print(f"Refresh failed: {e}")
        return

    # Call Gemini API via REST
    print("Calling Gemini API...")
    url = "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent"
    headers = {
        "Authorization": f"Bearer {creds.token}",
        "Content-Type": "application/json"
    }
    data = {
        "contents": [{"parts": [{"text": "Hello! Answer in one short sentence in Russian."}]}]
    }
    
    try:
        r = httpx.post(url, json=data, headers=headers, timeout=10.0)
        print("Status:", r.status_code)
        if r.status_code == 200:
            res_data = r.json()
            text = res_data["candidates"][0]["content"]["parts"][0]["text"]
            print("Response:", text)
        else:
            print("Error response:", r.text)
    except Exception as e:
        print(f"Request failed: {e}")

if __name__ == "__main__":
    test()

Youez - 2016 - github.com/yon3zu
LinuXploit