oauth-pkce-flow

Implement OAuth 2.1 with PKCE for CLI authentication flows.

1|2|Updated Dec 4, 2025
One-click install
npx skills add https://github.com/co-labs-co/context-harness --skill oauth-pkce-flow
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: oauth-pkce-flow
Source: https://github.com/co-labs-co/context-harness/tree/main/.opencode/skill/oauth-pkce-flow
Command: npx skills add https://github.com/co-labs-co/context-harness --skill oauth-pkce-flow

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

CLI applications often struggle to securely authenticate users against external providers without exposing credentials or compromising tokens. This skill provides a PKCE-based OAuth 2.1 flow with secure token storage and automatic refresh, suitable for CLI tools and SDKs.

Core Features & Use Cases

  • PKCE with S256 is mandatory for public clients.
  • Secure token storage using system keyring with file-based fallback.
  • Automatic token refresh with a 60-second expiration buffer.
  • Provider templates to easily add new OAuth providers.
  • CLI/SDK integration and debugging guidance.

Quick Start

Authenticate a provider (for example, GitHub) by invoking the OAuth flow via the CLI (for example, context-harness mcp auth github) and complete the browser-based login. Tokens are stored securely and refreshed automatically.

Frequently Asked Questions about oauth-pkce-flow

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

FAQPage Schema
How do I implement OAuth 2.1 with PKCE in a CLI application?

OAuth 2.1 with PKCE secures CLI authentication by mandating the S256 method for public clients. It uses browser-based authorization and state CSRF protection to prevent credential exposure during the token exchange.

What is the best way to store and refresh OAuth tokens in a command line tool?

Secure token storage uses the system keyring with a file-based fallback for CLI tools. Automatic token refresh occurs using a 60-second expiration buffer to ensure valid credentials without requiring user intervention.

How does PKCE with S256 protect public clients during browser-based authentication?

PKCE with S256 protects public clients by binding the authorization request to the token request using a hashed code challenge. This prevents interception attacks where a malicious actor might steal the authorization code from the browser flow.

Can I use provider templates to add new OAuth integrations to my SDK?

Configurable provider templates allow you to easily add new OAuth providers to CLI tools and SDKs. You can authenticate a provider like GitHub by invoking the OAuth flow via the CLI and completing the browser-based login.

Does OAuth PKCE flow support automatic token refresh when tokens expire?

Automatic token refresh is supported with a 60-second expiration buffer to maintain valid sessions. When the stored tokens approach expiration, the flow automatically requests new tokens using the stored refresh token.