JeffJing commited on
Commit
e4dec06
·
1 Parent(s): 24cb829

Update steamship/cli/login.py

Browse files
Files changed (1) hide show
  1. steamship/cli/login.py +1 -52
steamship/cli/login.py CHANGED
@@ -7,56 +7,5 @@ from steamship.base.error import SteamshipError
7
 
8
 
9
  def login(api_base: str, web_base: str) -> str: # noqa: C901
10
-
11
- # create login token
12
- try:
13
- token_result = requests.post(api_base + "account/create_login_attempt")
14
- token_data = token_result.json().get("data")
15
- except Exception as e:
16
- raise SteamshipError("Could not create login token when attempting login.", error=e)
17
-
18
- if token_data is None:
19
- raise SteamshipError("Could not create login token when attempting login.")
20
- token = token_data.get("token")
21
- if token is None:
22
- raise SteamshipError("Could not create login token when attempting login.")
23
-
24
- # Launch login attempt in browser
25
- login_browser_url = (
26
- f"{web_base}account/client-login?attemptToken={token}&client=pycli&version=0.0.1"
27
- )
28
- try:
29
- opened_browser = webbrowser.open(login_browser_url)
30
- except Exception as e:
31
- raise SteamshipError("Exception attempting to launch browser for login.", error=e)
32
-
33
- if not opened_browser:
34
- raise SteamshipError(
35
- """Could not launch browser to log in to Steamship.
36
-
37
- If you are in Replit:
38
-
39
- 1) Get an API key at https://steamship.com/account/api
40
- 2) Set the STEAMSHIP_API_KEY Replit Secret
41
- 3) Close and reopen this shell so that secrets refresh
42
-
43
- If you are in a different headless environment, visit https://docs.steamship.com/configuration/authentication.html"""
44
- )
45
-
46
- # Wait on result
47
- total_poll_time_s = 0
48
- time_between_polls_s = 1
49
- api_key = None
50
- while total_poll_time_s < 300: # Five minutes
51
- params = {"token": token}
52
- login_response = requests.post(f"{api_base}account/poll_login_attempt", json=params).json()
53
- if login_response.get("data", {}).get("status") == "done":
54
- api_key = login_response.get("data", {}).get("apiKey")
55
- break
56
- time.sleep(time_between_polls_s)
57
- total_poll_time_s += time_between_polls_s
58
-
59
- if api_key is None:
60
- raise SteamshipError("Could not fetch api key after login attempt in allotted time.")
61
-
62
  return api_key
 
7
 
8
 
9
  def login(api_base: str, web_base: str) -> str: # noqa: C901
10
+ api_key = '319649F9-F862-418B-8671-AFAD6C7A0879'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  return api_key