Go SDK
Installation
Section titled “Installation”go get github.com/authpipe-dev/authpipe-goZero external dependencies — stdlib only.
Configuration
Section titled “Configuration”import "github.com/authpipe-dev/authpipe-go"
// Default configuration (cache enabled, 5min TTL)client := authpipe.NewClient("sk_...")
// With optionsclient := 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 cachingclient := authpipe.NewClient("sk_...", authpipe.WithoutCache())| Option | Default | Description |
|---|---|---|
WithBaseURL(url) | https://api.authpipe.dev | API base URL |
WithAPIVersion(v) | 2026-04-07 | API version header |
WithCache(ttl) | 5 minutes | Credential cache TTL |
WithoutCache() | — | Disable credential caching |
WithHTTPClient(c) | 30s timeout | Custom HTTP client |
All methods accept a context.Context as their first parameter.
Credentials
Section titled “Credentials”GetCredential
Section titled “GetCredential”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 keyresult.CredentialType // string — "oauth_token", "api_key", etc.result.Source // string — "connection" or "installation"result.ExpiresAt // *string — RFC3339 expiryresult.Scopes // []stringStoreCredential
Section titled “StoreCredential”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 // stringresult.Status // stringOAuth Sessions
Section titled “OAuth Sessions”CreateAuthSession
Section titled “CreateAuthSession”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 // stringsession.AuthorizationURL // string — redirect the user hereCreateInstallSession
Section titled “CreateInstallSession”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"},})Connections
Section titled “Connections”GetConnection
Section titled “GetConnection”conn, err := client.GetConnection(ctx, "conn_abc123")DeleteConnection
Section titled “DeleteConnection”err := client.DeleteConnection(ctx, "conn_abc123")RefreshConnection
Section titled “RefreshConnection”result, err := client.RefreshConnection(ctx, "conn_abc123")result.Refreshed // boolresult.ExpiresAt // *stringSearchConnections
Section titled “SearchConnections”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.Connectionresp.HasMore // boolresp.NextCursor // stringresp.Limit // int64Installations
Section titled “Installations”GetInstallation
Section titled “GetInstallation”inst, err := client.GetInstallation(ctx, "inst_abc123")DeleteInstallation
Section titled “DeleteInstallation”err := client.DeleteInstallation(ctx, "inst_abc123")SearchInstallations
Section titled “SearchInstallations”resp, err := client.SearchInstallations(ctx, &authpipe.SearchRequest{ Filter: map[string]map[string]interface{}{ "tenant_id": {"eq": "org_acme"}, },})Provider Configs
Section titled “Provider Configs”CreateProviderConfig
Section titled “CreateProviderConfig”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"},})GetProviderConfig
Section titled “GetProviderConfig”config, err := client.GetProviderConfig(ctx, "pcfg_abc123")UpdateProviderConfig
Section titled “UpdateProviderConfig”enabled := trueconfig, err := client.UpdateProviderConfig(ctx, "pcfg_abc123", &authpipe.UpdateProviderConfigParams{ ClientSecret: "new-secret", Scopes: []string{"channels:read", "chat:write"}, SigningKey: "signing-secret", Enabled: &enabled,})DeleteProviderConfig
Section titled “DeleteProviderConfig”err := client.DeleteProviderConfig(ctx, "pcfg_abc123")SearchProviderConfigs
Section titled “SearchProviderConfigs”resp, err := client.SearchProviderConfigs(ctx, &authpipe.SearchRequest{ Filter: map[string]map[string]interface{}{ "provider_id": {"eq": "slack"}, },})Providers (Catalog)
Section titled “Providers (Catalog)”GetProvider
Section titled “GetProvider”provider, err := client.GetProvider(ctx, "slack")SearchProviders
Section titled “SearchProviders”resp, err := client.SearchProviders(ctx, &authpipe.SearchRequest{ Query: "email", Limit: 10,})Custom Providers
Section titled “Custom Providers”CreateCustomProvider
Section titled “CreateCustomProvider”provider, err := client.CreateCustomProvider(ctx, &authpipe.CreateCustomProviderParams{ ID: "my-internal-api", Name: "My Internal API",})GetCustomProvider
Section titled “GetCustomProvider”provider, err := client.GetCustomProvider(ctx, "my-internal-api")UpdateCustomProvider
Section titled “UpdateCustomProvider”provider, err := client.UpdateCustomProvider(ctx, "my-internal-api", &authpipe.UpdateCustomProviderParams{ Name: "Updated Name",})DeleteCustomProvider
Section titled “DeleteCustomProvider”err := client.DeleteCustomProvider(ctx, "my-internal-api")ListCustomProviders
Section titled “ListCustomProviders”providers, err := client.ListCustomProviders(ctx)Events
Section titled “Events”SearchEvents
Section titled “SearchEvents”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,})API Keys
Section titled “API Keys”ListAPIKeys
Section titled “ListAPIKeys”keys, err := client.ListAPIKeys(ctx)CreateAPIKey
Section titled “CreateAPIKey”result, err := client.CreateAPIKey(ctx, &authpipe.CreateApiKeyParams{ Name: "Production", Role: "secret",})result.ID // stringresult.Key // string (only returned once)RevokeAPIKey
Section titled “RevokeAPIKey”err := client.RevokeAPIKey(ctx, "key_abc123")Webhook Config
Section titled “Webhook Config”GetWebhookConfig
Section titled “GetWebhookConfig”config, err := client.GetWebhookConfig(ctx)config.WebhookURL // stringconfig.HasSecret1 // boolconfig.HasSecret2 // boolSetWebhookConfig
Section titled “SetWebhookConfig”result, err := client.SetWebhookConfig(ctx, &authpipe.SetWebhookConfigParams{ WebhookURL: "https://yourapp.com/webhooks",})result.Secret // string (save this)RotateWebhookSecret
Section titled “RotateWebhookSecret”result, err := client.RotateWebhookSecret(ctx)result.Secret // new secretDeleteWebhookConfig
Section titled “DeleteWebhookConfig”err := client.DeleteWebhookConfig(ctx)Workspaces
Section titled “Workspaces”GetWorkspace
Section titled “GetWorkspace”ws, err := client.GetWorkspace(ctx, "ws_abc123")UpdateWorkspace
Section titled “UpdateWorkspace”ws, err := client.UpdateWorkspace(ctx, "ws_abc123", &authpipe.UpdateWorkspaceParams{ Name: "New Name",})Error handling
Section titled “Error handling”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).