MathisG
MathisG3w ago

How to access any Google Api (Google Tasks) from windmill ?

Hi there, coming in from n8n I'm having issues understanding what ressource type to use for google oatuh using a google cloud platform project. 1. Created the gcp project 2. Added the appopriate APIs 3. Created a web app client 4. Activated Google gcloud oatuh from dashboard 5. Created an associated ressource, asking for the appropriate google tasks API scopes 6. Logged in the pop-up But now I can't use the ressource because all it has stored is a private key of some sort and it is useless in that way :
import wmill
from googleapiclient.discovery import build

def main(task_list_id: str = "@default"):
"""
Fetch all tasks from Google Tasks using OAuth2.
"""
# Get OAuth2 token from Windmill
# You need to create a Google OAuth resource in Windmill
google_auth = wmill.get_resource("REDACTED")

# Build the service with OAuth credentials
service = build('tasks', 'v1', credentials=google_auth)

try:
# List all task lists
results = service.tasklists().list(maxResults=10).execute()
tasksLists = results.get("items", [])

if not tasksLists:
print("No task lists found.")
return {"task_lists": [], "message": "No task lists found"}

all_data = []
print("Task lists:")
for taskList in tasksLists:
print(f"{taskList['title']} ({taskList['id']})")

except Exception as err:
print(f"Error: {err}")
return {"error": str(err)}
import wmill
from googleapiclient.discovery import build

def main(task_list_id: str = "@default"):
"""
Fetch all tasks from Google Tasks using OAuth2.
"""
# Get OAuth2 token from Windmill
# You need to create a Google OAuth resource in Windmill
google_auth = wmill.get_resource("REDACTED")

# Build the service with OAuth credentials
service = build('tasks', 'v1', credentials=google_auth)

try:
# List all task lists
results = service.tasklists().list(maxResults=10).execute()
tasksLists = results.get("items", [])

if not tasksLists:
print("No task lists found.")
return {"task_lists": [], "message": "No task lists found"}

all_data = []
print("Task lists:")
for taskList in tasksLists:
print(f"{taskList['title']} ({taskList['id']})")

except Exception as err:
print(f"Error: {err}")
return {"error": str(err)}
4 Replies
rubenf
rubenf3w ago
Hi, i think we support gcloud resources but not in an oauth manner:
No description
rubenf
rubenf3w ago
we would need a gcloud_oauth resource type most likely
MathisG
MathisGOP3w ago
What I did was go to the instance setting and create a gcloud oauth. I provided it with the client ID and the secrets from Google cloud console with a project configured and with a web app client type And then in resources I used the gcloud oauth and gave him the proper scope related to Google task It asked me to login on another window And then I was able to use the token in my scripts ! But yes, a generic gcloud_oauth with scopes to provide would be a proper way to handle this case ✌️ Thanks for your answer!
rubenf
rubenf3w ago
👍

Did you find this page helpful?