Merge pull request #52 from Panniantong/fix/twitter-cookie-sync-issue50
fix: sync Twitter cookies to xreach session.json on configure
This commit is contained in:
commit
932837ff9a
1 changed files with 20 additions and 1 deletions
|
|
@ -704,7 +704,26 @@ def _cmd_configure(args):
|
|||
if auth_token and ct0:
|
||||
config.set("twitter_auth_token", auth_token)
|
||||
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)
|
||||
os.chmod(session_path, 0o600)
|
||||
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=" ")
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue