a digital person for bluesky

Fix Bluesky authentication to load credentials from config.yaml

- Update default_login() to use get_bluesky_config() instead of os.getenv()
- Update init_client() to load PDS_URI from config with fallback to env var
- Update all PDS_URI references to use config loader
- Remove username/password printouts for security

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

Changed files
+35 -12
+35 -12
bsky_utils.py
··· 208 save_session(username, session.export()) 209 210 def init_client(username: str, password: str) -> Client: 211 - pds_uri = os.getenv("PDS_URI") 212 - if pds_uri is None: 213 logger.warning( 214 - "No PDS URI provided. Falling back to bsky.social. Note! If you are on a non-Bluesky PDS, this can cause logins to fail. Please provide a PDS URI using the PDS_URI environment variable." 215 ) 216 - pds_uri = "https://bsky.social" 217 218 # Print the PDS URI 219 logger.debug(f"Using PDS URI: {pds_uri}") ··· 235 236 237 def default_login() -> Client: 238 - username = os.getenv("BSKY_USERNAME") 239 - password = os.getenv("BSKY_PASSWORD") 240 241 - print(f"Username: {username}") 242 - print(f"Password: {password}") 243 244 if username is None: 245 logger.error( ··· 634 logger.error("Missing access token or DID from session") 635 return None 636 637 - pds_host = os.getenv("PDS_URI", "https://bsky.social") 638 639 # Create acknowledgment record with null subject 640 now = datetime.now(timezone.utc).isoformat().replace("+00:00", "Z") ··· 708 logger.error("Missing access token or DID from session") 709 return None 710 711 - pds_host = os.getenv("PDS_URI", "https://bsky.social") 712 713 # Create acknowledgment record with stream.thought.ack type 714 now = datetime.now(timezone.utc).isoformat().replace("+00:00", "Z") ··· 784 logger.error("Missing access token or DID from session") 785 return None 786 787 - pds_host = os.getenv("PDS_URI", "https://bsky.social") 788 789 # Create tool call record 790 now = datetime.now(timezone.utc).isoformat().replace("+00:00", "Z") ··· 861 logger.error("Missing access token or DID from session") 862 return None 863 864 - pds_host = os.getenv("PDS_URI", "https://bsky.social") 865 866 # Create reasoning record 867 now = datetime.now(timezone.utc).isoformat().replace("+00:00", "Z")
··· 208 save_session(username, session.export()) 209 210 def init_client(username: str, password: str) -> Client: 211 + from config_loader import get_bluesky_config 212 + try: 213 + bluesky_config = get_bluesky_config() 214 + pds_uri = bluesky_config.get('pds_uri', 'https://bsky.social') 215 + except (ValueError, KeyError): 216 + pds_uri = os.getenv("PDS_URI", "https://bsky.social") 217 logger.warning( 218 + "Failed to load PDS URI from config. Using environment variable or default." 219 ) 220 221 # Print the PDS URI 222 logger.debug(f"Using PDS URI: {pds_uri}") ··· 238 239 240 def default_login() -> Client: 241 + from config_loader import get_bluesky_config 242 + try: 243 + bluesky_config = get_bluesky_config() 244 + username = bluesky_config['username'] 245 + password = bluesky_config['password'] 246 + except (ValueError, KeyError) as e: 247 + logger.error(f"Failed to load Bluesky configuration: {e}") 248 + exit() 249 250 251 if username is None: 252 logger.error( ··· 641 logger.error("Missing access token or DID from session") 642 return None 643 644 + from config_loader import get_bluesky_config 645 + try: 646 + pds_host = get_bluesky_config().get('pds_uri', 'https://bsky.social') 647 + except: 648 + pds_host = os.getenv("PDS_URI", "https://bsky.social") 649 650 # Create acknowledgment record with null subject 651 now = datetime.now(timezone.utc).isoformat().replace("+00:00", "Z") ··· 719 logger.error("Missing access token or DID from session") 720 return None 721 722 + from config_loader import get_bluesky_config 723 + try: 724 + pds_host = get_bluesky_config().get('pds_uri', 'https://bsky.social') 725 + except: 726 + pds_host = os.getenv("PDS_URI", "https://bsky.social") 727 728 # Create acknowledgment record with stream.thought.ack type 729 now = datetime.now(timezone.utc).isoformat().replace("+00:00", "Z") ··· 799 logger.error("Missing access token or DID from session") 800 return None 801 802 + from config_loader import get_bluesky_config 803 + try: 804 + pds_host = get_bluesky_config().get('pds_uri', 'https://bsky.social') 805 + except: 806 + pds_host = os.getenv("PDS_URI", "https://bsky.social") 807 808 # Create tool call record 809 now = datetime.now(timezone.utc).isoformat().replace("+00:00", "Z") ··· 880 logger.error("Missing access token or DID from session") 881 return None 882 883 + from config_loader import get_bluesky_config 884 + try: 885 + pds_host = get_bluesky_config().get('pds_uri', 'https://bsky.social') 886 + except: 887 + pds_host = os.getenv("PDS_URI", "https://bsky.social") 888 889 # Create reasoning record 890 now = datetime.now(timezone.utc).isoformat().replace("+00:00", "Z")