Documentation
¶
Overview ¶
Package common provides common utilities for integrations.
Index ¶
- Variables
- func Descriptor(uniqueName, displayName, logoURL string) sdktypes.Integration
- func HTTPError(w http.ResponseWriter, code int)
- func MigrateAuthType(ctx context.Context, v sdkservices.Vars, vsid sdktypes.VarScopeID) error
- func MigrateDateTimeToRFC3339(ctx context.Context, v sdkservices.Vars, vsid sdktypes.VarScopeID, ...) error
- func ReadAuthType(vs sdktypes.Vars) string
- func ReadConnectionVars(ctx context.Context, vars sdkservices.Vars, cid sdktypes.ConnectionID) (sdktypes.Vars, sdktypes.Status, error)
- func RegisterOAuthHandler(m *muxes.Muxes, i sdktypes.Integration, h http.HandlerFunc)
- func RegisterSaveHandler(m *muxes.Muxes, i sdktypes.Integration, h http.HandlerFunc)
- func RenameVar(ctx context.Context, v sdkservices.Vars, vsid sdktypes.VarScopeID, ...) error
- func SaveAuthType(r *http.Request, vars sdkservices.Vars, vsid sdktypes.VarScopeID) string
- func ServeStaticUI(m *muxes.Muxes, i sdktypes.Integration, fs embed.FS)
- type OAuthData
Constants ¶
This section is empty.
Variables ¶
var ( AuthTypeVar = sdktypes.NewSymbol("auth_type") OAuthAccessTokenVar = sdktypes.NewSymbol("oauth_access_token") OAuthExpiryVar = sdktypes.NewSymbol("oauth_expiry") OAuthRefreshTokenVar = sdktypes.NewSymbol("oauth_refresh_token") OAuthTokenTypeVar = sdktypes.NewSymbol("oauth_token_type") )
Functions ¶
func Descriptor ¶
func Descriptor(uniqueName, displayName, logoURL string) sdktypes.Integration
func HTTPError ¶ added in v0.14.4
func HTTPError(w http.ResponseWriter, code int)
func MigrateAuthType ¶ added in v0.14.4
func MigrateAuthType(ctx context.Context, v sdkservices.Vars, vsid sdktypes.VarScopeID) error
MigrateAuthType migrates a connection's "auth_type" variable from the old "oauth" value to the new "oauthDefault". It is assumed that the variable exists.
func MigrateDateTimeToRFC3339 ¶ added in v0.14.4
func MigrateDateTimeToRFC3339(ctx context.Context, v sdkservices.Vars, vsid sdktypes.VarScopeID, varName sdktypes.Symbol) error
MigrateDateTimeToRFC3339 migrates a connection's timestamp variable from the Time.String() format to RFC-3339 format. It is assumed that the variable exists. If the variable is already in RFC-3339 format, it is left unchanged. An otherwise unrecognized format is reported as an error.
func ReadAuthType ¶ added in v0.14.1
func ReadConnectionVars ¶ added in v0.14.1
func ReadConnectionVars(ctx context.Context, vars sdkservices.Vars, cid sdktypes.ConnectionID) (sdktypes.Vars, sdktypes.Status, error)
ReadConnectionVars returns the connection's variables, or an error if the connection is not initialized or accessible.
func RegisterOAuthHandler ¶
func RegisterOAuthHandler(m *muxes.Muxes, i sdktypes.Integration, h http.HandlerFunc)
RegisterOAuthHandler registers a webhook to handle the last step in a 3-legged OAuth 2.0 flow. This is the only step that requires an authenticated user context for database access. The handler function receives an incoming redirect request from AutoKitteh's generic OAuth service, which contains an OAuth token (if the OAuth flow was successful) and form parameters for debugging and validation.
func RegisterSaveHandler ¶
func RegisterSaveHandler(m *muxes.Muxes, i sdktypes.Integration, h http.HandlerFunc)
RegisterSaveHandler registers a webhook to handle saving connection variables. This is always the first step in initializing a connection, regardless of its auth type. It's also the last step for non-OAuth authentication types. The handler function requires an authenticated user context for database access.
func RenameVar ¶ added in v0.14.4
func RenameVar(ctx context.Context, v sdkservices.Vars, vsid sdktypes.VarScopeID, old, new sdktypes.Symbol) error
RenameVar renames a variable in the given connection scope. It does nothing if the variable doesn't already exist. This is useful for non-trivial data migrations.
func SaveAuthType ¶ added in v0.14.1
func SaveAuthType(r *http.Request, vars sdkservices.Vars, vsid sdktypes.VarScopeID) string
SaveAuthType saves the authentication type that the user selected for a connection. This will be redundant if/when the only way to initialize connections is via the web UI, therefore we do not care if this function fails to save it as a connection variable.
func ServeStaticUI ¶
ServeStaticUI registers an integration's static web content to AutoKitteh's internal user-authenticated HTTP server. User auth isn't actually required for serving these files, but it's impossible to use them (i.e. to initialize a connection) without authentication.
Types ¶
type OAuthData ¶ added in v0.14.1
type OAuthData struct { AccessToken string `var:"oauth_access_token,secret"` Expiry string `var:"oauth_expiry"` RefreshToken string `var:"oauth_refresh_token,secret"` TokenType string `var:"oauth_token_type"` }
OAuthData contains OAuth 2.0 token details.
func EncodeOAuthData ¶ added in v0.14.1
EncodeOAuthData encodes an OAuth 2.0 token into AutoKitteh connection variables.