API Methods
The SDK exposes several methods through SsoSdk.instance.
Token Store
Access the reactive token store via SsoSdk.instance.tokenStore:
final store = SsoSdk.instance.tokenStore;
// Current tokens (nullable)
final tokens = store.currentTokens;
final authToken = store.authToken; // String?
final refreshToken = store.refreshToken; // String?
// Check auth status
final isAuth = store.isAuthenticated; // bool
// Reactive stream
store.tokensStream.listen((tokens) {
if (tokens != null) {
print('Auth token: ${tokens.authToken}');
print('Refresh token: ${tokens.refreshToken}');
} else {
print('Logged out');
}
});
Auth Controller
Access the auth controller via SsoSdk.instance.authController:
final controller = SsoSdk.instance.authController;
// Observe auth state
controller.stateStream.listen((state) {
switch (state) {
case SsoAuthenticated(): print('Authenticated');
case SsoUnauthenticated(): print('Not authenticated');
case SsoAuthenticating(): print('In progress...');
case SsoTokenRefreshing(): print('Refreshing token...');
case SsoAuthError(:final error): print('Error: $error');
}
});
// Manual token refresh
final result = await controller.refreshToken();
switch (result) {
case SsoSuccess(): print('Refreshed');
case SsoFailure(:final error): print('Failed: ${error.message}');
}
// Logout
await controller.logout();
Get Access Token
Obtain an access token for the auth flow using your app's private token:
final authToken = await SsoSdk.instance.getAccessToken('your-private-token');
Get Side Application Info
Retrieve information about the application that initiated OAuth:
final info = await SsoSdk.instance.getSideApplicationInfo(
authToken: authToken,
);
// info.allowProviders — ['google', 'telegram', 'basic']
// info.accessToken.payload.redirectUrlOnSuccess
Get Countries
Retrieve the list of supported countries:
// Public endpoint (requires auth token)
final countries = await SsoSdk.instance.getCountries(authToken: authToken);
// Private endpoint (requires authenticated user)
final countries = await SsoSdk.instance.getCountriesPrivate();
Auth Screen (static)
final widget = SsoSdk.authScreen(
enabledProviders: [SsoProvider.emailPassword],
authToken: authToken,
onSuccess: (tokens) { /* ... */ },
);
See Auth Screen for full parameters.
Dispose
SsoSdk.dispose(); // Releases all resources