Documentation
¶
Overview ¶
Package `pipes` provides a client wrapping the WorkOS Pipes API.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
DefaultClient = &Client{
Endpoint: "https://api.workos.com",
}
)
DefaultClient is the client used by SetAPIKey and Pipes functions.
Functions ¶
Types ¶
type AccessToken ¶
type AccessToken struct {
// The OAuth access token value.
AccessToken string `json:"access_token"`
// The timestamp when the access token expires, or nil if it doesn't expire.
ExpiresAt *time.Time `json:"expires_at"`
// The scopes that have been granted for this access token.
Scopes []string `json:"scopes"`
// The scopes that were requested but have not been granted.
MissingScopes []string `json:"missing_scopes"`
}
AccessToken contains data about an OAuth access token for a data integration.
func GetAccessToken ¶
func GetAccessToken( ctx context.Context, opts GetAccessTokenOpts, ) (AccessToken, error)
GetAccessToken retrieves an OAuth access token for a third-party data provider on behalf of a user.
On success, returns the AccessToken. On failure, returns an error which may be a GetAccessTokenError (NotInstalled or NeedsReauthorization) that can be checked with errors.Is or type assertion.
type Client ¶
type Client struct {
// The WorkOS API Key. It can be found in https://dashboard.workos.com/api-keys.
APIKey string
// The http.Client that is used to manage Pipes requests 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 Pipes requests to the WorkOS API.
func (*Client) GetAccessToken ¶
func (c *Client) GetAccessToken( ctx context.Context, opts GetAccessTokenOpts, ) (AccessToken, error)
GetAccessToken retrieves an OAuth access token for a third-party data provider on behalf of a user.
On success, returns the AccessToken. On failure, returns an error which may be a GetAccessTokenError (NotInstalled or NeedsReauthorization) that can be checked with errors.Is or type assertion.
type GetAccessTokenError ¶
type GetAccessTokenError string
GetAccessTokenError represents the error type when an access token cannot be retrieved.
const ( NotInstalled GetAccessTokenError = "not_installed" )
Constants that enumerate the available access token errors.
func (GetAccessTokenError) Error ¶
func (e GetAccessTokenError) Error() string
type GetAccessTokenOpts ¶
type GetAccessTokenOpts struct {
// Provider is the data provider identifier (e.g., "salesforce").
Provider string `json:"-"`
// UserID is the ID of the user requesting the token.
UserID string `json:"user_id"`
// OrganizationID is the optional organization context for the token.
OrganizationID string `json:"organization_id,omitempty"`
}
GetAccessTokenOpts contains the options to request an access token.