Add api key to flatpak up

This commit is contained in:
Bernd Schoolmann 2024-01-04 22:41:33 +01:00
parent 0f33ed3d08
commit 64286ce759
No known key found for this signature in database
3 changed files with 28 additions and 4 deletions

View File

@ -107,9 +107,9 @@ var setNotificationsURLCmd = &cobra.Command{
}
var setApiClientIDCmd = &cobra.Command{
Use: "set-api-client-id",
Short: "Set the api client id",
Long: `Set the api client id.`,
Use: "set-client-id",
Short: "Set the client id",
Long: `Set the client id.`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {
return
@ -140,7 +140,7 @@ var setApiClientIDCmd = &cobra.Command{
}
var setApiSecretCmd = &cobra.Command{
Use: "set-api-client-secret",
Use: "set-client-secret",
Short: "Set the api secret",
Long: `Set the api secret.`,
Run: func(cmd *cobra.Command, args []string) {

View File

@ -27,6 +27,18 @@ def set_notification_url(url):
if result.returncode != 0:
raise Exception("Failed to initialize repository, err", result.stderr)
def set_client_id(client_id):
restic_cmd = f"{BINARY_PATH} config set-client-id {client_id}"
result = subprocess.run(restic_cmd.split(), capture_output=True, text=True)
if result.returncode != 0:
raise Exception("Failed err", result.stderr)
def set_client_secret(client_secret):
restic_cmd = f"{BINARY_PATH} config set-client-secret {client_secret}"
result = subprocess.run(restic_cmd.split(), capture_output=True, text=True)
if result.returncode != 0:
raise Exception("Failed err", result.stderr)
def login_with_password(email, password):
restic_cmd = f"{BINARY_PATH} vault login --email {email}"
result = subprocess.run(restic_cmd.split(), capture_output=True, text=True)

View File

@ -282,6 +282,16 @@ def show_login():
email_entry.set_text("")
auth_preference_group.add(email_entry)
client_id_entry = Adw.EntryRow()
client_id_entry.set_title("Client ID (optional)")
client_id_entry.set_text("")
auth_preference_group.add(client_id_entry)
client_secret_entry = Adw.EntryRow()
client_secret_entry.set_title("Client Secret (optional)")
client_secret_entry.set_text("")
auth_preference_group.add(client_secret_entry)
dialog.add_button("Login", Gtk.ResponseType.OK)
def on_save(res):
if res != Gtk.ResponseType.OK:
@ -289,6 +299,8 @@ def show_login():
goldwarden.set_api_url(api_url_entry.get_text())
goldwarden.set_identity_url(identity_url_entry.get_text())
goldwarden.set_notification_url(notification_url_entry.get_text())
goldwarden.set_client_id(client_id_entry.get_text())
goldwarden.set_client_secret(client_secret_entry.get_text())
def login():
res = goldwarden.login_with_password(email_entry.get_text(), "password")
def handle_res():