MathisGM
Windmillโ€ข3mo agoโ€ข
4 replies
MathisG

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)}
Was this page helpful?