-
Notifications
You must be signed in to change notification settings - Fork 134
Expand file tree
/
Copy pathlaunchpad_auth_simple.py
More file actions
42 lines (34 loc) · 1.21 KB
/
launchpad_auth_simple.py
File metadata and controls
42 lines (34 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python3
"""
Simple Launchpad authentication for remote/SSH sessions.
"""
from launchpadlib.launchpad import Launchpad
from launchpadlib.credentials import Credentials
from launchpadlib.uris import lookup_service_root
import os
import webbrowser
# Disable automatic browser opening
webbrowser.register('none', None, webbrowser.GenericBrowser('echo'), -1)
webbrowser._tryorder = ['none']
print("Setting up Launchpad API authentication...")
print()
# Use a credential store
cred_dir = os.path.expanduser("~/.cache/byobu-launchpad")
os.makedirs(cred_dir, exist_ok=True)
try:
# This will print a URL for the user to visit
launchpad = Launchpad.login_with(
'byobu-cleanup-tool',
'production',
version='devel',
credential_save_failed=lambda: None # Don't fail if we can't save yet
)
print("\n✅ Authentication successful!")
# Test the connection
byobu = launchpad.projects['byobu']
print(f"✅ Successfully connected to project: {byobu.display_name}")
print("\nYou're all set! I can now interact with Launchpad on your behalf.")
except Exception as e:
print(f"\n❌ Error during authentication: {e}")
import traceback
traceback.print_exc()