--- /dev/null
+# 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 }}"