Create client
Create the SDK client and run core auth helpers
Create a Scalekit client with your environment URL, client ID, and client secret. All other clients hang off this instance.
Store credentials in environment variables. Never hard-code secrets. After you create the client, use Sessions or domain clients such as Organizations and Users.
GetAuthorizationUrl
Section titled “GetAuthorizationUrl”#asyncGetAuthorizationUrl
Runs GetAuthorizationUrl and returns the result.
Redirect uri.
Optional request settings.
url.URL
authURL, err := scalekitClient.GetAuthorizationUrl( "https://yourapp.com/auth/callback", scalekit.AuthorizationUrlOptions{ State: "random-state-value", OrganizationId: "org_123", },)if err != nil { // handle}
// Redirect user to authURL.String()AuthenticateWithCode
Section titled “AuthenticateWithCode”#asyncAuthenticateWithCode
Runs AuthenticateWithCode and returns the result.
Request context
Authorization code.
Redirect uri.
Optional request settings.
Authentication.
resp, err := scalekitClient.AuthenticateWithCode( ctx, code, "https://yourapp.com/auth/callback", scalekit.AuthenticationOptions{},)if err != nil { // handle}
accessToken := resp.AccessTokenuser := resp.User_ = accessToken_ = userGetIdpInitiatedLoginClaims
Section titled “GetIdpInitiatedLoginClaims”#asyncGetIdpInitiatedLoginClaims
Runs GetIdpInitiatedLoginClaims and returns the result.
Request context
Idp initiate login token.
The response payload for this operation.
claims, err := scalekitClient.GetIdpInitiatedLoginClaims(ctx, idpInitiatedLoginToken)if err != nil { // handle}
// claims.ConnectionID, claims.OrganizationID, claims.LoginHint, claims.RelayState_ = claimsGetAccessTokenClaims
Section titled “GetAccessTokenClaims”#asyncGetAccessTokenClaims
Runs GetAccessTokenClaims and returns the result.
Request context
Access token.
The response payload for this operation.
claims, err := scalekitClient.GetAccessTokenClaims(ctx, accessToken)if err != nil { // handle}_ = claimsValidateAccessToken
Section titled “ValidateAccessToken”#asyncValidateAccessToken
Runs ValidateAccessToken and returns the result.
Request context
Access token.
bool
ok, err := scalekitClient.ValidateAccessToken(ctx, accessToken)if err != nil { // invalid}_ = okRefreshAccessToken
Section titled “RefreshAccessToken”#asyncRefreshAccessToken
Runs RefreshAccessToken and returns the result.
Request context
Refresh token.
Token.
tokens, err := scalekitClient.RefreshAccessToken(ctx, refreshToken)if err != nil { // handle}_ = tokens.AccessTokenGetLogoutUrl
Section titled “GetLogoutUrl”#asyncGetLogoutUrl
Runs GetLogoutUrl and returns the result.
Optional request settings.
url.URL
logoutURL, err := scalekitClient.GetLogoutUrl(scalekit.LogoutUrlOptions{ IdTokenHint: idToken, PostLogoutRedirectUri: "https://yourapp.com/", State: "state",})if err != nil { // handle}_ = logoutURLVerifyWebhookPayload
Section titled “VerifyWebhookPayload”#asyncVerifyWebhookPayload
Runs VerifyWebhookPayload and returns the result.
Secret.
Headers.
Payload.
bool
valid, err := scalekitClient.VerifyWebhookPayload( "whsec_...", map[string]string{ "webhook-id": "webhook_123", "webhook-timestamp": "1730000000", "webhook-signature": "v1,base64sig", }, []byte(`{"event":"user.created","data":{"id":"123"}}`),)if err != nil { // handle}_ = validVerifyInterceptorPayload
Section titled “VerifyInterceptorPayload”#asyncVerifyInterceptorPayload
Runs VerifyInterceptorPayload and returns the result.
Secret.
Headers.
Payload.
bool
valid, err := scalekitClient.VerifyInterceptorPayload(secret, headers, payload)if err != nil { // handle}_ = validConnection
Section titled “Connection”#asyncConnection
Runs Connection and returns the result.
Connection.
Organization
Section titled “Organization”#asyncOrganization
Runs Organization and returns the result.
Organization.
#asyncUser
Runs User and returns the result.
User service.
Domain
Section titled “Domain”#asyncDomain
Runs Domain and returns the result.
Domain.
Directory
Section titled “Directory”#asyncDirectory
Runs Directory and returns the result.
Directory.
Session
Section titled “Session”#asyncSession
Runs Session and returns the result.
Session service.
#asyncRole
Runs Role and returns the result.
Role service.
Permission
Section titled “Permission”#asyncPermission
Runs Permission and returns the result.
Permission service.
Passwordless
Section titled “Passwordless”#asyncPasswordless
Runs Passwordless and returns the result.
Passwordless service.
WebAuthn
Section titled “WebAuthn”#asyncWebAuthn
Runs WebAuthn and returns the result.
Web authn service.
#asyncAuth
Runs Auth and returns the result.
Auth service.
Client
Section titled “Client”#asyncClient
Runs Client and returns the result.
Client service.
#asyncToken
Runs Token and returns the result.
Token service.
ValidateTokenWithOptions
Section titled “ValidateTokenWithOptions”#asyncValidateTokenWithOptions
ValidateTokenWithOptions validates a signed JWT (access token or ID token) and enforces optional checks such as audience and scope validation.
Request context
Token string.
Optional request settings.
bool
valid, err := scalekitClient.ValidateTokenWithOptions(ctx, accessToken, &scalekit.ValidateTokenOptions{ Audience: []string{"my-api"}, Scopes: []string{"read", "write"},})if err != nil { // handle}_ = validValidateToken
Section titled “ValidateToken”#asyncValidateToken
Runs ValidateToken and returns the result.
Request context
Token string.
Verified claims or result.
claims, err := scalekitClient.ValidateToken(ctx, idToken)if err != nil { // handle}_ = claimsWithSecret
Section titled “WithSecret”#asyncWithSecret
Runs WithSecret and returns the result.
Client secret.
Scalekit.
clientWithNewSecret := scalekitClient.WithSecret("new_client_secret")GenerateClientToken
Section titled “GenerateClientToken”#asyncGenerateClientToken
GenerateClientToken creates a client-credentials access token.
Request context
Optional request settings.
Client token.
resp, err := scalekitClient.GenerateClientToken(ctx, scalekit.GenerateClientTokenOptions{ ClientID: "service_client_id", ClientSecret: "service_client_secret", Scopes: []string{"read", "write"},})if err != nil { // handle}_ = resp.AccessTokenGetClientAccessToken
Section titled “GetClientAccessToken”#asyncGetClientAccessToken
Runs GetClientAccessToken and returns the result.
Request context
string
accessToken, err := scalekitClient.GetClientAccessToken(ctx)if err != nil { // handle}_ = accessTokenUnmarshalJSON
Section titled “UnmarshalJSON”#asyncUnmarshalJSON
Runs UnmarshalJSON and returns the result.
Data.
error
#asyncM2M
Runs M2M and returns the result.
M2mservice.
VerifyPayloadSignature
Section titled “VerifyPayloadSignature”#asyncVerifyPayloadSignature
Runs VerifyPayloadSignature and returns the result.
Secret.
Headers.
Payload.
bool