Skip to main content
Each recipe includes the problem, solution code, and rationale.

API key authentication

Problem: Connect to an API that uses API key in the Authorization header. Solution:
Why: The SDK’s uhttp package handles retries and rate limiting automatically. WithBearerToken sets Authorization: Bearer <token>.

OAuth2 client credentials

Problem: Exchange client ID and secret for an access token. Solution:
Why: The clientcredentials package handles token refresh automatically. You don’t need to manage token expiry.

JWT service account (Google-style)

Problem: Authenticate with a service account JSON key file. Solution:
Why: Domain-wide delegation requires impersonating a domain admin. The Subject field specifies which user to impersonate.

LDAP bind

Problem: Connect to Active Directory or LDAP server. Solution:
Why: LDAP requires binding before any queries. Simple bind uses credentials; external bind uses OS-level Kerberos tickets.