Skip to content

Authentication strategies

Adapter design. This page specifies the unpublished adapter. Run a request with Octokit and Effect.

Wrap the configured client’s auth(...args) lazily. Preserve its actual result type where the strategy exposes it and its upstream unknown boundary otherwise. First-class strategy bindings expose their callable authenticators and .hook, including overloaded authentication options and factory-returned clients. Distinguish configuring a strategy, obtaining authentication and authenticating an individual request.

Strategy Semantics to preserve
No auth, token/PAT, Actions and unauthenticated Core’s no-auth behavior, token classification, Actions environment discovery and explicit unauthenticated reason are different contracts. Environment reads belong in acquisition.
GitHub App App JWT, installation token, user auth, OAuth app auth, installation selection, repository IDs/names, permission restriction, expiration, refresh/bypass-cache options, factory mode, custom signing and cache where supported.
OAuth app and OAuth user Client credentials, code exchange, device flow, existing user token, token expiry and refresh behavior. Retain strategy-specific methods and discriminated results.
Device and callback Deliver verification URI/code and interval via the strategy’s callback. Preserve backoff, denial, expiry and callback rejection. A callback strategy may obtain credentials from the application.

Let the original strategy own signing, token exchange, cache keys, coalescing, expiration and request hooks. Never recreate a client’s auth context from an extracted token. The same installation with different permissions, repository sets, hosts or app identity can represent different authority. Avoid a process-global token cache. Do not log credentials, private keys or device codes. A borrowed auth API or polling loop may continue after fiber interruption if it lacks signal support. Prove cancellation before documenting it.

Check. Compare upstream and adapter auth for a supplied client with a custom strategy, two installations and different permission sets, simultaneous refreshes, expired/denied device flows and a rejected credential callback. Use synthetic credentials with a fake transport. Auth strategies · App auth · OAuth device auth