Skip to content

Go SDK

Terminal window
go get github.com/authpipe-dev/authpipe-go

Zero external dependencies — stdlib only.

import "github.com/authpipe-dev/authpipe-go"
// Default configuration (cache enabled, 5min TTL)
client := authpipe.NewClient("sk_...")
// With options
client := authpipe.NewClient("sk_...",
authpipe.WithBaseURL("https://api.authpipe.dev"),
authpipe.WithAPIVersion("2026-04-07"),
authpipe.WithCache(10 * time.Minute),
authpipe.WithHTTPClient(&http.Client{Timeout: 60 * time.Second}),
)
// Disable caching
client := authpipe.NewClient("sk_...", authpipe.WithoutCache())
OptionDefaultDescription
WithBaseURL(url)https://api.authpipe.devAPI base URL
WithAPIVersion(v)2026-04-07API version header
WithCache(ttl)5 minutesCredential cache TTL
WithoutCache()Disable credential caching
WithHTTPClient(c)30s timeoutCustom HTTP client

All methods accept a context.Context as their first parameter.

result, err := client.GetCredential(ctx, &authpipe.GetCredentialParams{
Provider: "slack",
TenantID: "org_acme",
UserID: "user_jane", // optional
InstallationID: ptr("inst_123"), // optional (*string)
CredentialFor: "any", // optional: "any", "installation", "user"
})
result.Credential // string — access token or API key
result.CredentialType // string — "oauth_token", "api_key", etc.
result.Source // string — "connection" or "installation"
result.ExpiresAt // *string — RFC3339 expiry
result.Scopes // []string
result, err := client.StoreCredential(ctx, &authpipe.StoreCredentialParams{
Provider: "sendgrid",
TenantID: "org_acme",
CredentialType: "api_key",
Credential: "SG.xxxx",
UserID: "", // optional
InstallationID: nil, // optional
})
result.ConnectionID // string
result.Status // string
session, err := client.CreateAuthSession(ctx, &authpipe.CreateAuthSessionParams{
Provider: "google",
TenantID: "org_acme",
UserID: "user_jane",
RedirectURL: "https://yourapp.com/callback",
Scopes: []string{"drive.readonly"},
InstallationID: nil,
TemplateVariables: map[string]string{"shop": "acme"},
})
session.SessionID // string
session.AuthorizationURL // string — redirect the user here
session, err := client.CreateInstallSession(ctx, &authpipe.CreateInstallSessionParams{
Provider: "slack",
TenantID: "org_acme",
UserID: "user_admin",
RedirectURL: "https://yourapp.com/installed",
Permissions: []string{"channels:read", "chat:write"},
})
conn, err := client.GetConnection(ctx, "conn_abc123")
err := client.DeleteConnection(ctx, "conn_abc123")
result, err := client.RefreshConnection(ctx, "conn_abc123")
result.Refreshed // bool
result.ExpiresAt // *string
resp, err := client.SearchConnections(ctx, &authpipe.SearchRequest{
Filter: map[string]map[string]interface{}{
"tenant_id": {"eq": "org_acme"},
"status": {"eq": "active"},
},
Sort: []authpipe.SortDirective{{Field: "connected_at", Direction: "desc"}},
Cursor: "",
Limit: 25,
})
resp.Data // []authpipe.Connection
resp.HasMore // bool
resp.NextCursor // string
resp.Limit // int64
inst, err := client.GetInstallation(ctx, "inst_abc123")
err := client.DeleteInstallation(ctx, "inst_abc123")
resp, err := client.SearchInstallations(ctx, &authpipe.SearchRequest{
Filter: map[string]map[string]interface{}{
"tenant_id": {"eq": "org_acme"},
},
})
config, err := client.CreateProviderConfig(ctx, &authpipe.CreateProviderConfigParams{
ProviderID: "slack",
ClientID: "your-client-id",
ClientSecret: "your-client-secret",
OAuthRedirectURL: "https://api.authpipe.dev/oauth/callback",
Attachment: "user",
Enabled: true,
Scopes: []string{"channels:read"},
})
config, err := client.GetProviderConfig(ctx, "pcfg_abc123")
enabled := true
config, err := client.UpdateProviderConfig(ctx, "pcfg_abc123", &authpipe.UpdateProviderConfigParams{
ClientSecret: "new-secret",
Scopes: []string{"channels:read", "chat:write"},
SigningKey: "signing-secret",
Enabled: &enabled,
})
err := client.DeleteProviderConfig(ctx, "pcfg_abc123")
resp, err := client.SearchProviderConfigs(ctx, &authpipe.SearchRequest{
Filter: map[string]map[string]interface{}{
"provider_id": {"eq": "slack"},
},
})
provider, err := client.GetProvider(ctx, "slack")
resp, err := client.SearchProviders(ctx, &authpipe.SearchRequest{
Query: "email",
Limit: 10,
})
provider, err := client.CreateCustomProvider(ctx, &authpipe.CreateCustomProviderParams{
ID: "my-internal-api",
Name: "My Internal API",
})
provider, err := client.GetCustomProvider(ctx, "my-internal-api")
provider, err := client.UpdateCustomProvider(ctx, "my-internal-api", &authpipe.UpdateCustomProviderParams{
Name: "Updated Name",
})
err := client.DeleteCustomProvider(ctx, "my-internal-api")
providers, err := client.ListCustomProviders(ctx)
resp, err := client.SearchEvents(ctx, &authpipe.SearchRequest{
Filter: map[string]map[string]interface{}{
"event_type": {"eq": "connection.created"},
},
Sort: []authpipe.SortDirective{{Field: "created_at", Direction: "desc"}},
Limit: 50,
})
keys, err := client.ListAPIKeys(ctx)
result, err := client.CreateAPIKey(ctx, &authpipe.CreateApiKeyParams{
Name: "Production",
Role: "secret",
})
result.ID // string
result.Key // string (only returned once)
err := client.RevokeAPIKey(ctx, "key_abc123")
config, err := client.GetWebhookConfig(ctx)
config.WebhookURL // string
config.HasSecret1 // bool
config.HasSecret2 // bool
result, err := client.SetWebhookConfig(ctx, &authpipe.SetWebhookConfigParams{
WebhookURL: "https://yourapp.com/webhooks",
})
result.Secret // string (save this)
result, err := client.RotateWebhookSecret(ctx)
result.Secret // new secret
err := client.DeleteWebhookConfig(ctx)
ws, err := client.GetWorkspace(ctx, "ws_abc123")
ws, err := client.UpdateWorkspace(ctx, "ws_abc123", &authpipe.UpdateWorkspaceParams{
Name: "New Name",
})
result, err := client.GetCredential(ctx, params)
if err != nil {
var apiErr *authpipe.APIError
if errors.As(err, &apiErr) {
fmt.Println(apiErr.StatusCode) // HTTP status
fmt.Println(apiErr.Code) // Error code
fmt.Println(apiErr.Message) // Human-readable message
fmt.Println(apiErr.RequestID) // X-Request-Id
}
}

The SDK automatically retries on 429 and 5xx with exponential backoff + jitter (up to 3 attempts).