Cookies 7

This commit is contained in:
Guillem Hernandez Sola
2026-05-19 11:18:48 +02:00
parent 998c18af8d
commit ee54aa4a25

View File

@@ -210,10 +210,23 @@ def bsky_login(client: Client, handle: str, password: str,
base_url: str) -> bool:
for attempt in range(1, BSKY_LOGIN_MAX_RETRIES + 1):
try:
client.base_url = base_url
client.login(handle, password)
logging.info(f"✅ Logged in to Bluesky as {handle} via {base_url}")
# Force the client to use the custom PDS for ALL requests
# including identity resolution — must be set before login
client._base_url = base_url.rstrip("/")
client.base_url = base_url.rstrip("/")
# Use com.atproto.server.createSession directly on the PDS
response = client.com.atproto.server.create_session(
data={
"identifier": handle,
"password": password,
}
)
logging.info(
f"✅ Logged in to Bluesky as {handle} via {base_url}"
)
return True
except Exception as e:
err = str(e)
@@ -221,14 +234,18 @@ def bsky_login(client: Client, handle: str, password: str,
if any(x in err for x in ("401", "AuthenticationRequired",
"Invalid identifier", "Invalid password")):
logging.error(
f"❌ Bluesky login failed: invalid handle or app password. "
f"Check your BSKY_JIJANTESFC_APP_PASSWORD credential in Jenkins. "
f"({err})"
f"❌ Bluesky login failed: invalid handle or app password.\n"
f" Handle : {handle}\n"
f" PDS : {base_url}\n"
f" Fix : regenerate app password at {base_url}/settings\n"
f" Detail : {err}"
)
return False
if attempt == BSKY_LOGIN_MAX_RETRIES:
logging.error(f"❌ All {BSKY_LOGIN_MAX_RETRIES} login attempts failed.")
logging.error(
f"❌ All {BSKY_LOGIN_MAX_RETRIES} login attempts failed."
)
return False
delay = min(
@@ -244,7 +261,6 @@ def bsky_login(client: Client, handle: str, password: str,
return False
def bsky_get_recent_post_urls(client: Client, handle: str,
limit: int = 50) -> set:
"""Return a set of URLs recently posted to Bluesky (to avoid duplicates)."""