npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@loopstack/google-oauth-calendar-example

v0.1.6

Published

An example module demonstrating how to fetch Google Calendar events with OAuth authentication using the Loopstack automation framework. Shows the sub-workflow pattern for handling OAuth flows.

Readme

@loopstack/google-oauth-calendar-example

An example module for the Loopstack AI automation framework.

This module demonstrates how to build a workflow that fetches data from an OAuth-protected API (Google Calendar) and handles authentication automatically using the sub-workflow pattern with @loopstack/oauth-module.

Overview

The Google OAuth Calendar Example shows a real-world pattern: attempt an API call, and if the user is not authenticated, launch the OAuth workflow as an embedded sub-workflow. Once the user completes sign-in, the parent workflow automatically retries.

By using this example as a reference, you'll learn how to:

  • Use OAuthTokenStore to check for valid tokens before making API calls
  • Launch the OAuth workflow as a sub-workflow via ExecuteWorkflowAsync
  • Display the OAuth flow inline using an embedded LinkDocument with embed: true and expanded: true
  • Automatically retry after authentication completes via the callback transition
  • Render results using MarkdownDocument

Installation

See SETUP.md for installation and setup instructions.

How It Works

Workflow Flow

start → fetch_events → calendar_fetched
                          ├── (unauthorized) → auth_required → awaiting_auth
                          │                                       ↓
                          │                                  auth_completed → start (retry)
                          └── (success) → display_results → end

1. Fetching Calendar Events

The GoogleCalendarFetchEventsTool checks for a valid Google OAuth token via OAuthTokenStore.getValidAccessToken(). If no token exists, it returns { error: "unauthorized" } instead of throwing, allowing the workflow to branch:

- tool: googleCalendarFetchEvents
  args:
    calendarId: ${{ args.calendarId }}
    timeMin: ${{ now() }}
    timeMax: ${{ endOfWeek() }}
  assign:
    requiresAuthentication: ${{ result.data.error == "unauthorized" }}
    events: ${{ result.data.events }}

2. Launching OAuth as a Sub-Workflow

If authentication is required, the workflow uses ExecuteWorkflowAsync to launch the generic OAuth workflow as a child. A LinkDocument with embed: true and expanded: true renders the OAuth flow inline as an iframe so the user can authenticate without leaving the page:

- id: auth_required
  from: calendar_fetched
  to: awaiting_auth
  if: ${{ state.requiresAuthentication }}
  call:
    - tool: executeWorkflowAsync
      id: launchAuth
      args:
        workflow: oAuth
        args:
          provider: 'google'
          scopes:
            - 'https://www.googleapis.com/auth/calendar.readonly'
        callback:
          transition: auth_completed

    - tool: createDocument
      args:
        id: authStatus
        document: linkDocument
        update:
          content:
            icon: 'LockKeyhole'
            label: 'Google authentication required'
            caption: 'Complete sign-in to continue'
            href: '/pipelines/{{ runtime.tools.auth_required.launchAuth.data.task.pipelineId }}'
            embed: true
            expanded: true

3. Automatic Retry

When the OAuth sub-workflow completes, the event system triggers auth_completed on the parent, which transitions back to start — automatically re-fetching the calendar events with the now-valid token:

- id: auth_completed
  from: awaiting_auth
  to: start
  trigger: manual

Dependencies

This example uses the following Loopstack modules:

  • @loopstack/core — Core framework functionality including ExecuteWorkflowAsync
  • @loopstack/oauth-module — OAuth infrastructure (OAuthTokenStore, OAuthWorkflow)
  • @loopstack/core-ui-module — Provides CreateDocument, LinkDocument, and MarkdownDocument
  • @loopstack/create-chat-message-tool — Provides CreateChatMessage

A Google OAuth provider module (implementing OAuthProviderInterface) is also required.

About

Author: Jakob Klippel

License: Apache-2.0

Additional Resources