Skip to content
Skillv1.0.0

authentication-patterns

Authentication patterns for external services: API keys, OAuth, token management, verification. Triggers: authentication, API keys, OAuth, token management, credentials Use when: integrating external

by majiayu000(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from majiayu000/claude-skill-registry-data (security/authentication-patterns/SKILL.md). Install upstream with npx skills add majiayu000/claude-skill-registry-data --skill authentication-patterns. Copyright stays with the author.

Authentication Patterns

Overview

Common authentication patterns for integrating with external services. Provides consistent approaches to credential management, verification, and error handling.

When to Use

  • Integrating with external APIs
  • Need credential verification
  • Managing multiple auth methods
  • Handling auth failures gracefully

Authentication Methods

Method Best For Environment Variable
API Key Simple integrations {SERVICE}_API_KEY
OAuth User-authenticated Browser-based flow
Token Session-based {SERVICE}_TOKEN
None Public APIs N/A

Quick Start

Verify Authentication

from leyline.auth import verify_auth, AuthMethod

# API Key verification
status = verify_auth(
    service="gemini",
    method=AuthMethod.API_KEY,
    env_var="GEMINI_API_KEY"
)

if not status.authenticated:
    print(f"Auth failed: {status.message}")
    print(f"Action: {status.suggested_action}")

Smoke Test

def verify_with_smoke_test(service: str) -> bool:
    """Verify auth with simple request."""
    result = execute_simple_request(service, "ping")
    return result.success

Standard Flow

Step 1: Check Environment

def check_credentials(service: str, env_var: str) -> bool:
    value = os.getenv(env_var)
    if not value:
        print(f"Missing {env_var}")
        return False
    return True

Step 2: Verify with Service

def verify_with_service(service: str) -> AuthStatus:
    result = subprocess.run(
        [service, "auth", "status"],
        capture_output=True
    )
    return AuthStatus(
        authenticated=(result.returncode == 0),
        message=result.stdout.decode()
    )

Step 3: Handle Failures

def handle_auth_failure(service: str, method: AuthMethod) -> str:
    actions = {
        AuthMethod.API_KEY: f"Set {service.upper()}_API_KEY environment variable",
        AuthMethod.OAUTH: f"Run '{service} auth login' for browser auth",
        AuthMethod.TOKEN: f"Refresh token with '{service} token refresh'"
    }
    return actions[method]

Integration Pattern

# In your skill's frontmatter
dependencies: [leyline:authentication-patterns]

Detailed Resources

  • Auth Methods: See modules/auth-methods.md for method details
  • Verification: See modules/verification-patterns.md for testing patterns

Exit Criteria

  • Credentials verified or clear failure message
  • Suggested action for auth failures
  • Smoke test confirms working auth

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/majiayu000-claude-skill-registry-data-authentication-patterns/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

majiayu000-claude-skill-registry-data-authentication-patterns.ocm.jsonjson
{
  "ocm": "1",
  "id": "majiayu000-claude-skill-registry-data-authentication-patterns",
  "kind": "skill",
  "name": "authentication-patterns",
  "description": "Authentication patterns for external services: API keys, OAuth, token management, verification. Triggers: authentication, API keys, OAuth, token management, credentials Use when: integrating external services or implementing authentication flows",
  "publisher": "majiayu000",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "coding"
    ],
    "tags": [
      "skill-md",
      "authentication",
      "api-keys",
      "oauth",
      "tokens",
      "security",
      "github"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Authentication patterns for external services: API keys, OAuth, token management, verification. Triggers: authentication, API keys, OAuth, token management, credentials Use when: integrating external services or implementing authentication flows"
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "github",
      "repository": "https://github.com/majiayu000/claude-skill-registry-data",
      "path": "security/authentication-patterns/SKILL.md",
      "ref": "f863c11651055f498e1466492dc2a0d95721d2d5",
      "url": "https://github.com/majiayu000/claude-skill-registry-data/blob/f863c11651055f498e1466492dc2a0d95721d2d5/security/authentication-patterns/SKILL.md",
      "key": "majiayu000/claude-skill-registry-data/security/authentication-patterns/SKILL.md"
    }
  },
  "instructions": "# Authentication Patterns\n\n## Overview\n\nCommon authentication patterns for integrating with external services. Provides consistent approaches to credential management, verification, and error handling.\n\n## When to Use\n\n- Integrating with external APIs\n- Need credential verification\n- Managing multiple auth methods\n- Handling auth failures gracefully\n\n## Authentication Methods\n\n| Method | Best For | Environment Variable |\n|--------|----------|---------------------|\n| API Key | Simple integrations | `{SERVICE}_API_KEY` |\n| OAuth | User-authenticated | Browser-based flow |\n| Token | Session-based",
  "cost": {
    "context_tokens": 646
  }
}

Fetch it by URL: GET /api/v1/registry/majiayu000-claude-skill-registry-data-authentication-patterns/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.