b2bstytchapi

package
v15.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	Discovery     *b2b.DiscoveryClient
	M2M           *consumer.M2MClient
	MagicLinks    *b2b.MagicLinksClient
	OAuth         *b2b.OAuthClient
	OTPs          *b2b.OTPsClient
	Organizations *b2b.OrganizationsClient
	Passwords     *b2b.PasswordsClient
	Project       *consumer.ProjectClient
	RBAC          *b2b.RBACClient
	RecoveryCodes *b2b.RecoveryCodesClient
	SCIM          *b2b.SCIMClient
	SSO           *b2b.SSOClient
	Sessions      *b2b.SessionsClient
	TOTPs         *b2b.TOTPsClient
	// contains filtered or unexported fields
}

func NewClient

func NewClient(projectID string, secret string, opts ...Option) (*API, error)

NewClient returns a Stytch API client that uses the provided credentials.

It detects the environment from the given projectID. You are still free to pass WithBaseURI as an option if you wish to override this behavior, but the intention is to provide a simpler interface for creating a client since it's extremely rare that developers would want to use something other than the detected environment.

type Logger

type Logger interface {
	Printf(format string, v ...any)
}

type Option

type Option func(*API)

func WithBaseURI

func WithBaseURI(uri string) Option

WithBaseURI overrides the client base URI determined by the environment.

The value derived from stytch.EnvLive or stytch.EnvTest is already correct for production use in the Live or Test environment, respectively. This is implemented to make it easier to use this client to access internal development versions of the API.

NOTE: You should not use this in conjunction with the WithClient option since WithClient completely overrides the stytch.Client with one that may not be a stytch.DefaultClient.

func WithClient

func WithClient(client stytch.Client) Option

WithClient overrides the stytch.Client used by the API client. This is useful for completely mocking out requests by using something like GoMock against the stytch.Client interface to customize the responses you receive from API methods.

NOTE: You should not use this in conjunction with WithHTTPClient or WithBaseURI since the latter two assume usage of the default stytch.DefaultClient and this method completely overrides it to use anything conforming to the interface.

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient overrides the HTTP client used by the API client. The default value is &http.Client{}.

NOTE: You should not use this in conjunction with the WithClient option since WithClient completely overrides the stytch.Client with one that may not be a stytch.DefaultClient.

func WithInitializationContext

func WithInitializationContext(ctx context.Context) Option

WithInitializationContext overrides the context used during initialization.

The context argument is used only during client setup and can be used to cancel client creation. After the client is created and returned, canceling the context has no effect. It is preferred to use this function over the less flexible NewAPIClientWithContext function, which will be deprecated in a future MAJOR release.

func WithLogger

func WithLogger(logger Logger) Option

func WithSkipJWKSInitialization

func WithSkipJWKSInitialization() Option

WithSkipJWKSInitialization skips the initialization of the JWKS client. This can be useful for testing purposes. Please note that if you utilize this option, any API method that makes use of the JWKS client will raise a stytcherror.JWKSNotInitialized error. If you need to call such a method, you should use WithClient or WithHTTPClient with a client that is capable of ininitalizing the JWKS keyfunc.

Jump to

Keyboard shortcuts

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