summaryrefslogtreecommitdiff
path: root/src/authenticator.vala
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2024-02-22 17:32:27 +0100
committerJörg Frings-Fürst <debian@jff.email>2024-02-22 17:32:27 +0100
commit2bb26608f735b6fc90c06a56793e1cf6e164830a (patch)
tree0b7ca7dcaaeb737b7e539ce4c3992d18c6949370 /src/authenticator.vala
parent5c6c59a0325c2f3cc611b8186ac289d011c14369 (diff)
parent5303f650e34763817d7eeb1d3ba774bdec3e1a38 (diff)
Update upstream source from tag 'upstream/0.32.6'
Update to upstream version '0.32.6' with Debian dir 5219d541f047c3ea70dcf1edb7897dd0a7dedfb1
Diffstat (limited to 'src/authenticator.vala')
-rw-r--r--src/authenticator.vala40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/authenticator.vala b/src/authenticator.vala
new file mode 100644
index 0000000..55f3321
--- /dev/null
+++ b/src/authenticator.vala
@@ -0,0 +1,40 @@
+// SPDX-License-Identifer: LGPL-2.1-or-later
+// SPDX-FileCopyrightText: 2022 Jens Georg <mail@jensge.org>
+
+[DBus(name = "org.gnome.Shotwell.Authenticate")]
+public interface AuthenticationReceiver : Object {
+ public abstract void callback(string url) throws DBusError, IOError;
+}
+
+static int main(string[] args) {
+ AuthenticationReceiver receiver;
+
+ if (args.length != 2) {
+ print("Usage: %s <callback-uri>\n", args[0]);
+ return 1;
+ }
+
+ try {
+ var uri = Uri.parse(args[1], UriFlags.NONE);
+ var scheme = uri.get_scheme();
+
+ if (scheme != "shotwell-oauth2" && !scheme.has_prefix("com.googleusercontent.apps")) {
+ critical("Invalid scheme in callback URI \"%s\"", args[1]);
+ return 1;
+ }
+ } catch (Error e) {
+ critical("Invalid uri: \"%s\": %s", args[1], e.message);
+ return 1;
+ }
+
+ try {
+ receiver = Bus.get_proxy_sync (BusType.SESSION, "org.gnome.Shotwell", "/org/gnome/Shotwell");
+ receiver.callback(args[1]);
+ } catch (Error e) {
+ critical("Could not connect to remote shotwell instance: %s", e.message);
+
+ return 1;
+ }
+
+ return 0;
+} \ No newline at end of file