This Chat is read-only. Login to resume chatting.
from fxa.core import Client
import requests
import json
# Replace these with your Firefox account credentials
FXA_EMAIL = "your_firefox_account_email@example.com"
FXA_PASSWORD = "your_firefox_account_password"
# If you use a custom Sync Key, provide it here. Otherwise, leave as None.
SYNC_KEY = None # or "your_sync_key_here"
def get_firefox_sync_tabs():
# Step 1: Authenticate with Firefox Accounts
client = Client()
session = client.login(FXA_EMAIL, FXA_PASSWORD, "Firefox Sync Tabs Script")
# Step 2: Get the Sync tokens
tokens = session.get_sync_tokens()
access_token = tokens["access_token"]
sync_key = SYNC_KEY or tokens.get("kB", None)
if not sync_key:
raise ValueError("No Sync Key found. Check if you use a custom Sync Key.")
# Step 3: Fetch synced tabs
headers = {
"Authorization": f"Bearer {access_token}",
}
response = requests.get(
"https://sync-1-us-west2.sync.services.mozilla.com/1.5/your_fxa_uid/storage/tabs",
headers=headers,
)
if response.status_code == 200:
tabs_data = response.json()
tabs = tabs_data.get("tabs", [])
for client in tabs:
print(f"Client: {client.get('title', 'Unknown Device')}")
for tab in client.get("tabs", []):
print(f" - {tab.get('title', 'No Title')} ({tab.get('urlHistory', ['No URL'])[0]})")
else:
print(f"Failed to fetch tabs: {response.status_code} - {response.text}")
if __name__ == "__main__":
get_firefox_sync_tabs()