fix: sync Twitter cookies to xreach session.json on configure
When running 'agent-reach configure twitter-cookies', credentials are now automatically written to ~/.config/xfetch/session.json so that 'xreach auth check' works without manual intervention. Preserves existing session.json fields if the file already exists. Falls back gracefully if the sync fails (still saves to agent-reach config). Fixes #50
This commit is contained in:
+19
-1
@@ -704,7 +704,25 @@ def _cmd_configure(args):
|
|||||||
if auth_token and ct0:
|
if auth_token and ct0:
|
||||||
config.set("twitter_auth_token", auth_token)
|
config.set("twitter_auth_token", auth_token)
|
||||||
config.set("twitter_ct0", ct0)
|
config.set("twitter_ct0", ct0)
|
||||||
print(f"✅ Twitter cookies configured!")
|
|
||||||
|
# Sync credentials to xreach's session.json so xreach auth check works
|
||||||
|
try:
|
||||||
|
import json
|
||||||
|
xfetch_dir = os.path.join(os.path.expanduser("~"), ".config", "xfetch")
|
||||||
|
os.makedirs(xfetch_dir, exist_ok=True)
|
||||||
|
session_path = os.path.join(xfetch_dir, "session.json")
|
||||||
|
session_data = {}
|
||||||
|
if os.path.exists(session_path):
|
||||||
|
with open(session_path, "r", encoding="utf-8") as sf:
|
||||||
|
session_data = json.load(sf)
|
||||||
|
session_data["authToken"] = auth_token
|
||||||
|
session_data["ct0"] = ct0
|
||||||
|
with open(session_path, "w", encoding="utf-8") as sf:
|
||||||
|
json.dump(session_data, sf, indent=2)
|
||||||
|
print("✅ Twitter cookies configured (synced to xreach)!")
|
||||||
|
except Exception as e:
|
||||||
|
print("✅ Twitter cookies configured!")
|
||||||
|
print(f"⚠️ Could not sync to xreach session.json: {e}")
|
||||||
|
|
||||||
print("Testing Twitter access...", end=" ")
|
print("Testing Twitter access...", end=" ")
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user