Documentation
¶
Overview ¶
Package `passwordless` provides a client wrapping the WorkOS Magic Link API.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
DefaultClient = &Client{
Endpoint: "https://api.workos.com",
}
)
DefaultClient is the client used by the SetAPIKey, CreateSession, and SendSession functions.
Functions ¶
func SendSession ¶
func SendSession( ctx context.Context, opts SendSessionOpts, ) error
SendSession sends a Passwordless Session via email
Types ¶
type Client ¶
type Client struct {
// The WorkOS API Key.
// It can be found in https://dashboard.workos.com/api-keys.
//
// REQUIRED
APIKey string
// The http.Client that is used to send request to WorkOS.
//
// Defaults to http.Client.
HTTPClient *http.Client
// The endpoint to WorkOS API.
//
// Defaults to https://api.workos.com.
Endpoint string
// The function used to encode in JSON. Defaults to json.Marshal.
JSONEncode func(v interface{}) ([]byte, error)
// contains filtered or unexported fields
}
Client represents a client that performs Passwordless requests to the WorkOS API.
func (*Client) CreateSession ¶
func (c *Client) CreateSession(ctx context.Context, opts CreateSessionOpts) (PasswordlessSession, error)
CreateSession creates a a PasswordlessSession.
func (*Client) SendSession ¶
func (c *Client) SendSession( ctx context.Context, opts SendSessionOpts, ) error
SendSession sends a Passwordless Session via email
type CreateSessionOpts ¶
type CreateSessionOpts struct {
// The email of the user to authenticate.
//
// REQUIRED
Email string `json:"email"`
// The type of Passwordless Session to create.
//
// REQUIRED
Type PasswordlessSessionType `json:"type"`
// Optional The unique identifier for a WorkOS Connection.
Connection string `json:"connection"`
// Optional string value used to set the location
// that the user will be redirected to after authenticating
RedirectURI string `json:"redirect_uri"`
// Optional string value used to manage application state
// between authorization transactions.
State string `json:"state"`
// Optional The number of seconds the Passwordless Session
// should live before expiring.
ExpiresIn int `json:"expires_in"`
}
CreateSessionOpts contains the options to create a Passowordless Session.
type PasswordlessSession ¶
type PasswordlessSession struct {
// The Passwordless Session's unique identifier.
ID string `json:"id"`
// The email of the user to authenticate.
Email string `json:"email"`
// ISO-8601 datetime at which the Passwordless Session link expires.
ExpiresAt string `json:"expires_at"`
// The link for the user to authenticate with.
Link string `json:"link"`
}
PasswordlessSession contains data about a WorkOS Passwordless Session.
func CreateSession ¶
func CreateSession( ctx context.Context, opts CreateSessionOpts, ) (PasswordlessSession, error)
CreateSession creates a new Passwordless Session
type PasswordlessSessionType ¶
type PasswordlessSessionType string
CreateSessionType represents the type of a Passwordless Session.
const (
MagicLink PasswordlessSessionType = "MagicLink"
)
Constants that enumerate the available PasswordlessSessionType values.
type SendSessionOpts ¶
type SendSessionOpts struct {
// Passwordless Session unique identifier.
SessionID string
}
SendSessionOpts contains the options to send a Passwordless Session via email.