corbado

package module
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2023 License: MIT Imports: 21 Imported by: 0

README

Corbado Go SDK

Go SDK for Corbado Backend API

Go Reference Test Status documentation Go Report Card

Requirements

The SDK supports Go version 1.18 and above.

Usage

$ go get github.com/corbado/corbado-go@v0.5.0

Import SDK in your Go files:

import "github.com/corbado/corbado-go"

Now create a new SDK client:

config := corbado.MustNewConfig("pro-12345678", "yoursecret")
sdk, err := corbado.NewSDK(config)
if err != nil {
	// handle error
}

// list all users
users, err := sdk.Users().List(context.TODO(), nil)
if err != nil {
    if serverErr := corbado.AsServerError(err); serverErr != nil {
	    // handle server error	
    }
}

See examples for some real example code

Documentation

Index

Constants

View Source
const Version = "v0.5.0"

Variables

This section is empty.

Functions

func AsServerError

func AsServerError(err error) *servererror.ServerError

AsServerError casts given error into a ServerError, if possible

func IsServerError

func IsServerError(err error) bool

IsServerError checks if given error is a ServerError

func MustNewConfig

func MustNewConfig(projectID string, apiSecret string) *config.Config

MustNewConfig returns new config and panics if projectID or apiSecret are not specified/empty this is a convenience function for config.NewConfig to avoid import cycles

func NewConfig

func NewConfig(projectID string, apiSecret string) (*config.Config, error)

NewConfig returns new config with sane defaults this is a convenience function for config.NewConfig to avoid import cycles

func NewLoggingClientOption

func NewLoggingClientOption() api.ClientOption

NewLoggingClientOption enhances HTTP client to log requests/responses

Types

type Impl

type Impl struct {
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

func NewSDK

func NewSDK(config *config.Config) (*Impl, error)

NewSDK returns new SDK

func (*Impl) AuthTokens

func (i *Impl) AuthTokens() authtoken.AuthToken

AuthTokens returns auth tokens client

func (*Impl) EmailCodes added in v0.5.0

func (i *Impl) EmailCodes() emailcode.EmailCode

EmailCodes returns email codes client

func (i *Impl) EmailLinks() emaillink.EmailLink

EmailLinks returns email links client

func (*Impl) Passkeys added in v0.5.0

func (i *Impl) Passkeys() passkey.Passkey

Passkeys returns passkeys client

func (*Impl) Projects added in v0.2.0

func (i *Impl) Projects() project.Project

Projects returns projects client

func (*Impl) Sessions

func (i *Impl) Sessions() session.Session

Sessions returns sessions client

func (*Impl) Templates added in v0.3.0

func (i *Impl) Templates() template.Template

Templates returns templates client

func (*Impl) Users

func (i *Impl) Users() user.User

Users returns users client

func (*Impl) Validations

func (i *Impl) Validations() validation.Validation

Validations returns validation client

type SDK

type SDK interface {
	AuthTokens() authtoken.AuthToken
	EmailCodes() emailcode.EmailCode
	EmailLinks() emaillink.EmailLink
	Passkeys() passkey.Passkey
	Projects() project.Project
	Sessions() session.Session
	Templates() template.Template
	Users() user.User
	Validations() validation.Validation
}

Directories

Path Synopsis
examples
basic command
pkg
sdk/entity/api
Package api provides primitives to interact with the openapi HTTP API.
Package api provides primitives to interact with the openapi HTTP API.
sdk/entity/common
Package common provides primitives to interact with the openapi HTTP API.
Package common provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL