Cookies 7
This commit is contained in:
@@ -210,10 +210,23 @@ def bsky_login(client: Client, handle: str, password: str,
|
|||||||
base_url: str) -> bool:
|
base_url: str) -> bool:
|
||||||
for attempt in range(1, BSKY_LOGIN_MAX_RETRIES + 1):
|
for attempt in range(1, BSKY_LOGIN_MAX_RETRIES + 1):
|
||||||
try:
|
try:
|
||||||
client.base_url = base_url
|
# Force the client to use the custom PDS for ALL requests
|
||||||
client.login(handle, password)
|
# including identity resolution — must be set before login
|
||||||
logging.info(f"✅ Logged in to Bluesky as {handle} via {base_url}")
|
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
|
return True
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
err = str(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",
|
if any(x in err for x in ("401", "AuthenticationRequired",
|
||||||
"Invalid identifier", "Invalid password")):
|
"Invalid identifier", "Invalid password")):
|
||||||
logging.error(
|
logging.error(
|
||||||
f"❌ Bluesky login failed: invalid handle or app password. "
|
f"❌ Bluesky login failed: invalid handle or app password.\n"
|
||||||
f"Check your BSKY_JIJANTESFC_APP_PASSWORD credential in Jenkins. "
|
f" Handle : {handle}\n"
|
||||||
f"({err})"
|
f" PDS : {base_url}\n"
|
||||||
|
f" Fix : regenerate app password at {base_url}/settings\n"
|
||||||
|
f" Detail : {err}"
|
||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if attempt == BSKY_LOGIN_MAX_RETRIES:
|
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
|
return False
|
||||||
|
|
||||||
delay = min(
|
delay = min(
|
||||||
@@ -244,7 +261,6 @@ def bsky_login(client: Client, handle: str, password: str,
|
|||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def bsky_get_recent_post_urls(client: Client, handle: str,
|
def bsky_get_recent_post_urls(client: Client, handle: str,
|
||||||
limit: int = 50) -> set:
|
limit: int = 50) -> set:
|
||||||
"""Return a set of URLs recently posted to Bluesky (to avoid duplicates)."""
|
"""Return a set of URLs recently posted to Bluesky (to avoid duplicates)."""
|
||||||
|
|||||||
Reference in New Issue
Block a user