From: Jakub Czajka Date: Wed, 27 Sep 2023 18:59:12 +0000 (+0200) Subject: Add a script for obtaining an access token for Google Drive. X-Git-Url: https://git.ekhem.eu.org/?a=commitdiff_plain;h=370ab6b41e2bc29199e0d1f0d0b584c564f36015;p=turnup.git Add a script for obtaining an access token for Google Drive. --- 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 }}"