alfadocs-oauth-token-refresh

Refresh AlfaDocs OAuth tokens with concurrency-safe row locking in Supabase Edge Functions.

Updated Mar 9, 2026
One-click install
npx skills add https://github.com/alfadocs/ai-harness-instructions --skill alfadocs-oauth-token-refresh
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: alfadocs-oauth-token-refresh
Source: https://github.com/alfadocs/ai-harness-instructions/tree/main/lovable/skills/alfadocs-oauth-token-refresh
Command: npx skills add https://github.com/alfadocs/ai-harness-instructions --skill alfadocs-oauth-token-refresh

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill prevents AlfaDocs OAuth connections from breaking when access tokens expire or refresh-token rotation happens, avoiding accidental lockouts and forced re-authentication.

Core Features & Use Cases

  • Safely refreshes expired AlfaDocs tokens with the refresh_token grant.
  • Enforces concurrency-safe row locking so two requests never rotate the same token at once.
  • Keeps tokens server-side in Supabase, scopes them per practice and archive, and handles revoked-token recovery with clear retry and re-auth logic.
  • Use it when an AlfaDocs API call returns 401 or 403, when a token is near expiry, or when you need a production-safe refresh workflow for multiple practices.

Quick Start

Ask the assistant to refresh AlfaDocs OAuth tokens safely for the specified practice while preserving server-side Supabase storage, row locking, and rotated refresh-token persistence.

Frequently Asked Questions about alfadocs-oauth-token-refresh

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refresh expired OAuth tokens in Supabase Edge Functions without breaking authentication?▼

To refresh expired OAuth tokens, apply a server-side workflow using the refresh_token grant in Supabase Edge Functions, ensuring concurrency-safe row locking to prevent simultaneous rotation errors and maintain continuous authentication.

Why does refresh-token rotation fail when multiple concurrent requests happen?▼

Refresh-token rotation fails during concurrent requests because multiple processes attempt to use or rotate the same token simultaneously. Enforcing concurrency-safe row locking ensures only one request rotates the token, while others wait, preventing invalidation and lockouts.

Can I use Supabase Edge Functions to manage multi-practice OAuth token isolation?▼

Yes, you can use Supabase Edge Functions to manage multi-practice OAuth token isolation by scoping tokens per practice and archive. This workflow requires server-only secret handling and proper nullish refresh-token persistence to maintain secure boundaries between practices.

What is the best way to handle 401 recovery for expired API tokens?▼

The best way to handle 401 recovery for expired API tokens is to proactively intercept the error, execute a server-side refresh_token grant, and update the stored token. Include revoked-token classification to distinguish between tokens needing retry and those requiring re-authentication.

How do I persist a nullish refresh token safely during server-side rotation?▼

To persist a nullish refresh token safely during server-side rotation, handle the token update on the server within Supabase, ensuring empty or null values do not overwrite valid tokens. This prevents data loss during the refresh-token rotation process.

When should I proactively renew access tokens instead of waiting for a 401 error?▼

You should proactively renew access tokens before expiry when managing multiple practices or high-volume API calls. This approach avoids latency from 401 recovery workflows and ensures tokens are refreshed safely using server-side logic without interrupting user sessions.