PHP SDK for Scalekit - Enterprise Authentication Platform
composer require pawanmore/scalekit-php-sdk<?php
require_once 'vendor/autoload.php';
use Scalekit\ScalekitClient;
// Initialize the client
$client = new ScalekitClient(
'https://your-environment.scalekit.cloud',
'your-client-id',
'your-client-secret'
);
// Get access token
$tokenResponse = $client->auth->getAccessToken();
// List organizations
$organizations = $client->organizations->listOrganizations();
// Create an organization
$newOrg = $client->organizations->createOrganization([
'display_name' => 'My Organization',
'region_code' => 'US'
]);The SDK uses OAuth2 client credentials flow for authentication:
// Get access token
$tokenResponse = $client->auth->getAccessToken();
// The token is automatically set and used for subsequent requestsgetAccessToken()- Get access token using client credentialsexchangeCodeForToken($code, $redirectUri)- Exchange authorization code for tokenrefreshToken($refreshToken)- Refresh access tokenrevokeToken($token)- Revoke access tokenintrospectToken($token)- Introspect tokengetUserInfo()- Get user info
listOrganizations($params)- List organizationssearchOrganizations($params)- Search organizationscreateOrganization($data)- Create organizationgetOrganization($id)- Get organization by IDgetOrganizationByExternalId($externalId)- Get organization by external IDupdateOrganization($id, $data)- Update organizationupdateOrganizationSettings($id, $settings)- Update organization settingsdeleteOrganization($id)- Delete organization
getAuthorizationUrl($params)- Generate authorization URL for SSOexchangeCodeForToken($code, $redirectUri)- Exchange code for token
listDirectories($params)- List all directoriesgetDirectory($id)- Get directorylistUsersInDirectory($directoryId, $params)- List users in directorylistGroupsInDirectory($directoryId, $params)- List groups in directoryenableDirectory($id)- Enable directorydisableDirectory($id)- Disable directory
listConnections($organizationId, $params)- List connectionsgetConnection($organizationId, $connectionId)- Get connectionenableConnection($organizationId, $connectionId)- Enable connectiongetConnectionProviders()- Get connection providers
listUsers($organizationId, $params)- List users in organizationcreateUser($organizationId, $userData)- Create user
sendPasswordless($organizationId, $data)- Send passwordless authenticationverifyPasswordless($organizationId, $data)- Verify passwordless authenticationresendPasswordless($organizationId, $data)- Resend passwordless authenticationcreatePasswordlessConnection($organizationId, $data)- Create passwordless connectionupdatePasswordlessConnection($organizationId, $connectionId, $data)- Update passwordless connectionenablePasswordlessConnection($organizationId, $connectionId)- Enable passwordless connection
createM2MClient($organizationId, $data)- Create M2M clientcreateM2MClientSecret($organizationId, $clientId)- Create M2M client secretgetM2MClient($organizationId, $clientId)- Get M2M clientrotateSecret($organizationId, $clientId)- Rotate M2M client secretupdateM2MClient($organizationId, $clientId, $data)- Update M2M client detailsgetM2MClientAccessToken($clientId, $clientSecret)- Get M2M client access tokendeleteM2MClientSecret($organizationId, $clientId, $secretId)- Delete M2M client secretdeleteM2MClient($organizationId, $clientId)- Delete M2M client
getJWKS()- Get JSON Web Key Set
getConfiguration()- Get OpenID configuration
generatePortalLink($organizationId, $data)- Generate admin portal link
getClient($clientId)- Get client by IDupdateClientRedirects($clientId, $redirects)- Update client redirects
// Generate authorization URL
$authUrl = $client->sso->getAuthorizationUrl([
'redirect_uri' => 'https://your-app.com/callback',
'organization_id' => 'org_123',
'scope' => 'openid email profile'
]);
// After user authentication, exchange code for token
$tokenResponse = $client->sso->exchangeCodeForToken($code, $redirectUri);// Create organization
$organization = $client->organizations->createOrganization([
'display_name' => 'Acme Corp',
'region_code' => 'US',
'metadata' => [
'industry' => 'Technology'
]
]);
// List organizations with pagination
$organizations = $client->organizations->listOrganizations();