Common authentication patterns for external service integration. Covers API keys, OAuth flows, token management, and verification strategies. Triggers: authentication, API keys, OAuth, token management, credentials, service authentication, credential verification, token refresh Use when: integrating external services, implementing authentication flows, managing API credentials, verifying service authentication DO NOT use when: simple services without authentication needs. Consult this skill when implementing authentication for external services.
/plugin marketplace add athola/claude-night-market/plugin install leyline@claude-night-marketThis skill inherits all available tools. When active, it can use any tool Claude has access to.
modules/auth-methods.mdmodules/verification-patterns.mdCommon authentication patterns for integrating with external services. Provides consistent approaches to credential management, verification, and error handling.
| 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 |
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}")
def verify_with_smoke_test(service: str) -> bool:
"""Verify auth with simple request."""
result = execute_simple_request(service, "ping")
return result.success
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
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()
)
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]
# In your skill's frontmatter
dependencies: [leyline:authentication-patterns]
modules/auth-methods.md for method detailsmodules/verification-patterns.md for testing patterns