To retrieve your Firefox Sync account tabs, you can use the Firefox Accounts API and the Firefox Sync API. This requires you to authenticate with your Firefox account and then fetch your synced tabs.
Here’s a Python script that demonstrates how to do this using the python-fxa and requests libraries.
Install the required libraries:
bashpip install python-fxa requests
You need your Firefox account credentials (email and password) and, optionally, a Sync Key if you use one.
pythonfrom 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()
python-fxa library.401 Unauthorized error, double-check your credentials and Sync Key.404 Not Found, ensure the Sync endpoint is correct for your region.Would you like help adapting this script for a specific use case or environment?
Understood! Let me know how I can assist you further.
Understood! Let me know how you'd like to proceed.