]> git.ekhem.eu.org Git - turnup.git/commitdiff
Add a script for obtaining an access token for Google Drive.
authorJakub Czajka <jakub@ekhem.eu.org>
Wed, 27 Sep 2023 18:59:12 +0000 (20:59 +0200)
committerJakub Czajka <jczajka@google.com>
Sun, 24 Dec 2023 18:46:45 +0000 (19:46 +0100)
gdrive_auth.yaml [new file with mode: 0644]

diff --git a/gdrive_auth.yaml b/gdrive_auth.yaml
new file mode 100644 (file)
index 0000000..76a6f45
--- /dev/null
@@ -0,0 +1,26 @@
+# Copyright (c) 2023 Jakub Czajka <jakub@ekhem.eu.org>
+# License: GPL-3.0 or later.
+
+- name: Print authentication URL
+  debug:
+    msg: "Please authenticate and grant permissions at https://accounts.google.com/o/oauth2/v2/auth?client_id={{ client_id }}&redirect_uri={{ redirect_uri }}&scope={{ scope }}&response_type=code"
+- name: Obtain authorization code
+  pause:
+    prompt: "Enter authentication code"
+  register: code
+- name: Obtain authorization token
+  uri:
+    url: "https://accounts.google.com/o/oauth2/token"
+    method: POST
+    body:
+      code: "{{ code.user_input }}"
+      client_id: "{{ client_id }}"
+      client_secret: "{{ client_secret }}"
+      redirect_uri: "{{ redirect_uri }}"
+      grant_type: "authorization_code"
+    body_format: json
+    status_code: 200
+  register: token
+- name: Remember the access token
+  set_fact:
+    access_token: "{{ token.json.access_token }}"