From 370ab6b41e2bc29199e0d1f0d0b584c564f36015 Mon Sep 17 00:00:00 2001 From: Jakub Czajka Date: Wed, 27 Sep 2023 20:59:12 +0200 Subject: [PATCH] Add a script for obtaining an access token for Google Drive. --- gdrive_auth.yaml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 gdrive_auth.yaml diff --git a/gdrive_auth.yaml b/gdrive_auth.yaml new file mode 100644 index 0000000..76a6f45 --- /dev/null +++ b/gdrive_auth.yaml @@ -0,0 +1,26 @@ +# Copyright (c) 2023 Jakub Czajka +# 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 }}" -- 2.39.5