Skip to content

SSO Client & Runtime Switching

Accessing client configuration

php
use Carro\SsoClient\Facades\SsoClient;

// Get client details
$clientId = SsoClient::getClientId();
$apiToken = SsoClient::getApiToken();
$baseUri = SsoClient::getBaseURI();

// Get all client configuration
$config = SsoClient::getConfig();

Runtime client switching (Facade)

php
use Carro\SsoClient\Facades\SsoClient;

// Switch to another configured client
SsoClient::shouldUse('other_client');

// Now all operations will use the other client's configuration
$otherClientId = SsoClient::getClientId();

Runtime client switching (Helper)

php
// Get default client
$defaultClient = client();
$defaultClientId = $defaultClient->getClientId();

// Get a specific client
$otherClient = client('other_client');
$otherClientId = $otherClient->getClientId();

// Switch to another configured client
client()->shouldUse('other_client');

// Now all operations will use the other client's configuration
$otherClientId = client()->getClientId();

Retrieving user data with different clients

php
use Carro\SsoClient\Facades\User;

// Get users with default client
$defaultUsers = User::all();

// Get users with a different client
client()->shouldUse('other_client');
$otherUsers = User::all();

// Return to default client
client()->shouldUse('default');

The MIT License (MIT). Please see License File in the repository for more information.