# Innovato SSO v1 Implementation Guide ## Overview Innovato SSO v1 provides a simple and secure way to integrate single sign-on functionality into your application. ## Prerequisites - Client ID from Innovato SSO service - Redirect URI (HTTPS required for production) - Modern browser with JavaScript enabled ## Installation ### 1. Add the SSO Script ```html <script src="https://your-sso-server.com/SSO/v1/SSO.js"></script> ``` ### 2. Initialize the SSO Client ```javascript const sso = new InnovatoSSOv1({ clientId: "your-client-id", redirectUri: "https://your-app.com/callback", baseUrl: "https://your-sso-server.com", container: "sso-button-container", // Optional theme: "light", // Optional: 'light' or 'dark' size: "normal", // Optional: 'small', 'normal', or 'large' }); ``` ## Configuration Options | Option | Type | Required | Default | Description | | ----------- | ------ | -------- | --------------------- | ------------------- | | clientId | string | Yes | - | Your SSO client ID | | redirectUri | string | Yes | - | Your callback URL | | baseUrl | string | Yes | - | SSO server base URL | | container | string | No | 'innovato-sso-button' | Button container ID | | theme | string | No | 'light' | Button theme | | size | string | No | 'normal' | Button size | ## Usage Examples ### Basic Implementation ```html <div id="innovato-sso-button"></div> <script> const sso = new InnovatoSSOv1({ clientId: "your-client-id", redirectUri: "https://your-app.com/callback", baseUrl: "https://your-sso-server.com", }); </script> ``` ### Custom Styling ```javascript const sso = new InnovatoSSOv1({ clientId: "your-client-id", redirectUri: "https://your-app.com/callback", baseUrl: "https://your-sso-server.com", theme: "dark", size: "large", }); ``` ## Methods ### login() Initiates the SSO login process. ```javascript sso.login() .then((response) => { console.log("User:", response.user); console.log("Token:", response.token); }) .catch((error) => { console.error("Login failed:", error); }); ``` ### logout() Logs out the current user. ```javascript sso.logout().then(() => { console.log("Logged out successfully"); }); ``` ### isAuthenticated() Checks if user is authenticated. ```javascript if (sso.isAuthenticated()) { console.log("User is logged in"); } ``` ### getToken() Retrieves the current access token. ```javascript const token = sso.getToken(); ``` ### getUser() Retrieves the current user data. ```javascript const user = sso.getUser(); ``` ## Error Handling The SSO client throws errors in these cases: - Missing required configuration - Invalid client ID - Network errors - Authentication failures Example error handling: ```javascript sso.login().catch((error) => { if (error.message === "Invalid client ID") { // Handle invalid client ID } else if (error.message.includes("network")) { // Handle network errors } }); ``` ## Security Considerations 1. Always use HTTPS in production 2. Validate tokens on your backend 3. Implement proper CORS policies 4. Store tokens securely 5. Implement proper error handling ## Browser Support - Chrome (latest) - Firefox (latest) - Safari (latest) - Edge (latest)