|
8 | 8 | from linkedin_mcp_server.exceptions import CredentialsNotFoundError
|
9 | 9 |
|
10 | 10 | from .providers import (
|
11 |
| - get_cookie_from_keyring, |
12 | 11 | get_credentials_from_keyring,
|
13 | 12 | get_keyring_name,
|
14 |
| - save_cookie_to_keyring, |
15 | 13 | save_credentials_to_keyring,
|
16 | 14 | )
|
17 | 15 |
|
18 | 16 | logger = logging.getLogger(__name__)
|
19 | 17 |
|
20 | 18 |
|
21 |
| -def has_authentication() -> bool: |
22 |
| - """Check if authentication is available without triggering interactive setup.""" |
23 |
| - config = get_config() |
24 |
| - |
25 |
| - # Check environment variable |
26 |
| - if config.linkedin.cookie: |
27 |
| - return True |
28 |
| - |
29 |
| - # Check keyring if enabled |
30 |
| - if config.linkedin.use_keyring: |
31 |
| - cookie = get_cookie_from_keyring() |
32 |
| - if cookie: |
33 |
| - return True |
34 |
| - |
35 |
| - return False |
36 |
| - |
37 |
| - |
38 |
| -def get_authentication() -> str: |
39 |
| - """Get LinkedIn cookie from keyring, environment, or interactive setup.""" |
40 |
| - config = get_config() |
41 |
| - |
42 |
| - # First, try environment variable |
43 |
| - if config.linkedin.cookie: |
44 |
| - logger.info("Using LinkedIn cookie from environment") |
45 |
| - return config.linkedin.cookie |
46 |
| - |
47 |
| - # Second, try keyring if enabled |
48 |
| - if config.linkedin.use_keyring: |
49 |
| - cookie = get_cookie_from_keyring() |
50 |
| - if cookie: |
51 |
| - logger.info(f"Using LinkedIn cookie from {get_keyring_name()}") |
52 |
| - return cookie |
53 |
| - |
54 |
| - # If in non-interactive mode and no cookie found, raise error |
55 |
| - if config.chrome.non_interactive: |
56 |
| - raise CredentialsNotFoundError( |
57 |
| - "No LinkedIn cookie found. Please provide cookie via " |
58 |
| - "environment variable (LINKEDIN_COOKIE) or run with --get-cookie to obtain one." |
59 |
| - ) |
60 |
| - |
61 |
| - # Otherwise, prompt for cookie or setup |
62 |
| - return prompt_for_authentication() |
63 |
| - |
64 |
| - |
65 | 19 | def get_credentials() -> Dict[str, str]:
|
66 | 20 | """Get LinkedIn credentials from config, keyring, or prompt (legacy for --get-cookie)."""
|
67 | 21 | config = get_config()
|
@@ -89,49 +43,6 @@ def get_credentials() -> Dict[str, str]:
|
89 | 43 | return prompt_for_credentials()
|
90 | 44 |
|
91 | 45 |
|
92 |
| -def prompt_for_authentication() -> str: |
93 |
| - """Prompt user for LinkedIn cookie or setup via login.""" |
94 |
| - print("🔗 LinkedIn MCP Server Setup") |
95 |
| - |
96 |
| - # Ask if user has a cookie |
97 |
| - has_cookie = inquirer.confirm("Do you have a LinkedIn cookie?", default=False) |
98 |
| - |
99 |
| - if has_cookie: |
100 |
| - cookie = inquirer.text("LinkedIn Cookie", validate=lambda _, x: len(x) > 10) |
101 |
| - if save_cookie_to_keyring(cookie): |
102 |
| - logger.info(f"Cookie stored securely in {get_keyring_name()}") |
103 |
| - else: |
104 |
| - logger.warning("Could not store cookie in system keyring.") |
105 |
| - logger.info("Your cookie will only be used for this session.") |
106 |
| - return cookie |
107 |
| - else: |
108 |
| - # Login flow to get cookie |
109 |
| - return setup_cookie_from_login() |
110 |
| - |
111 |
| - |
112 |
| -def setup_cookie_from_login() -> str: |
113 |
| - """Login with credentials and capture cookie.""" |
114 |
| - from linkedin_mcp_server.setup import capture_cookie_from_credentials |
115 |
| - |
116 |
| - print("🔑 LinkedIn login required to obtain cookie") |
117 |
| - credentials = prompt_for_credentials() |
118 |
| - |
119 |
| - # Use existing cookie capture functionality |
120 |
| - cookie = capture_cookie_from_credentials( |
121 |
| - credentials["email"], credentials["password"] |
122 |
| - ) |
123 |
| - |
124 |
| - if cookie: |
125 |
| - if save_cookie_to_keyring(cookie): |
126 |
| - logger.info(f"Cookie stored securely in {get_keyring_name()}") |
127 |
| - else: |
128 |
| - logger.warning("Could not store cookie in system keyring.") |
129 |
| - logger.info("Your cookie will only be used for this session.") |
130 |
| - return cookie |
131 |
| - else: |
132 |
| - raise CredentialsNotFoundError("Failed to obtain LinkedIn cookie") |
133 |
| - |
134 |
| - |
135 | 46 | def prompt_for_credentials() -> Dict[str, str]:
|
136 | 47 | """Prompt user for LinkedIn credentials and store them securely."""
|
137 | 48 | print(f"🔑 LinkedIn credentials required (will be stored in {get_keyring_name()})")
|
|
0 commit comments