UNPKG

onairos

Version:

The Onairos Library is a collection of functions that enable Applications to connect and communicate data with Onairos Identities via User Authorization. Integration for developers is seamless, simple and effective for all applications. LLM SDK capabiliti

183 lines (152 loc) โ€ข 6.92 kB
# OAuth Connector Gaps Filled ## ๐ŸŽฏ Using WEB_OAUTH_CONNECTORS_OVERVIEW.md Based on the comprehensive OAuth overview documentation, I've filled in the missing gaps in the Universal Onboarding connectors component. ## ๐Ÿ“Š Before vs After ### โŒ **Previous Platform List (8 platforms)** ```javascript const platforms = [ { name: 'YouTube', icon: '๐Ÿ“บ', color: 'bg-red-500', connector: 'youtube' }, { name: 'Reddit', icon: '๐Ÿ”ฅ', color: 'bg-orange-500', connector: 'reddit' }, { name: 'Instagram', icon: '๐Ÿ“ท', color: 'bg-pink-500', connector: 'instagram' }, { name: 'Pinterest', icon: '๐Ÿ“Œ', color: 'bg-red-600', connector: 'pinterest' }, { name: 'TikTok', icon: '๐ŸŽต', color: 'bg-black', connector: 'tiktok' }, // โŒ Not in OAuth overview { name: 'Twitter', icon: '๐Ÿฆ', color: 'bg-blue-500', connector: 'twitter' }, // โŒ Not in OAuth overview { name: 'LinkedIn', icon: '๐Ÿ’ผ', color: 'bg-blue-700', connector: 'linkedin' }, { name: 'Facebook', icon: '๐Ÿ‘ฅ', color: 'bg-blue-600', connector: 'facebook' } ]; ``` ### โœ… **Updated Platform List (9 platforms)** ```javascript const platforms = [ { name: 'YouTube', icon: '๐Ÿ“บ', color: 'bg-red-500', connector: 'youtube' }, { name: 'LinkedIn', icon: '๐Ÿ’ผ', color: 'bg-blue-700', connector: 'linkedin' }, { name: 'Reddit', icon: '๐Ÿ”ฅ', color: 'bg-orange-500', connector: 'reddit' }, { name: 'Pinterest', icon: '๐Ÿ“Œ', color: 'bg-red-600', connector: 'pinterest' }, { name: 'Instagram', icon: '๐Ÿ“ท', color: 'bg-pink-500', connector: 'instagram' }, { name: 'GitHub', icon: 'โšก', color: 'bg-gray-800', connector: 'github' }, // โœ… Added { name: 'Facebook', icon: '๐Ÿ‘ฅ', color: 'bg-blue-600', connector: 'facebook' }, { name: 'Gmail', icon: 'โœ‰๏ธ', color: 'bg-red-400', connector: 'gmail' }, // โœ… Added { name: 'Notion', icon: '๐Ÿ“', color: 'bg-gray-700', connector: 'notion' } // โœ… Added ]; ``` ## ๐Ÿ”„ Changes Made ### **Added Platforms** โœ… 1. **GitHub** - Developer platform integration - Endpoint: `/github/authorize` - Response: `githubURL` - Icon: โšก | Color: `bg-gray-800` 2. **Gmail** - Google email integration - Endpoint: `/gmail/authorize` - Response: `gmailURL` - Icon: โœ‰๏ธ | Color: `bg-red-400` 3. **Notion** - Productivity platform integration - Endpoint: `/notion/authorize` - Response: `notionURL` - Icon: ๐Ÿ“ | Color: `bg-gray-700` ### **Removed Platforms** โŒ 1. **TikTok** - Not documented in OAuth overview 2. **Twitter** - Not documented in OAuth overview ### **Enhanced URL Parsing** ๐Ÿ”ง #### Before (Generic) ```javascript const urlKey = `${platform.connector}URL`; const oauthUrl = result[urlKey] || result.platformURL || result.authUrl || result.url; ``` #### After (Specific Mapping) ```javascript const platformUrlKeys = { 'youtube': 'youtubeURL', 'linkedin': 'linkedinURL', 'reddit': 'redditURL', 'pinterest': 'pinterestURL', 'instagram': 'instagramURL', 'github': 'githubURL', // โœ… New 'facebook': 'facebookURL', 'gmail': 'gmailURL', // โœ… New 'notion': 'notionURL' // โœ… New }; const expectedUrlKey = platformUrlKeys[platform.connector]; const oauthUrl = result[expectedUrlKey] || result[`${platform.connector}URL`] || result.platformURL || result.authUrl || result.url; ``` ### **Improved Error Handling** ๐Ÿšจ #### Enhanced Error Messages ```javascript if (!oauthUrl) { console.error(`โŒ No OAuth URL received for ${platformName}:`); console.error(`Expected URL key: ${expectedUrlKey}`); console.error(`Response keys:`, Object.keys(result)); console.error(`Full response:`, result); throw new Error(`No OAuth URL found. Expected '${expectedUrlKey}' in response. Check API configuration for ${platformName}.`); } ``` ## ๐Ÿ“‹ Platform Mapping Reference Based on WEB_OAUTH_CONNECTORS_OVERVIEW.md, each platform follows this pattern: | Platform | Connector | Endpoint | Response Key | OAuth Provider | |----------|-----------|----------|--------------|----------------| | **YouTube** | `youtube` | `/youtube/authorize` | `youtubeURL` | Google OAuth | | **LinkedIn** | `linkedin` | `/linkedin/authorize` | `linkedinURL` | LinkedIn OAuth | | **Reddit** | `reddit` | `/reddit/authorize` | `redditURL` | Reddit OAuth | | **Pinterest** | `pinterest` | `/pinterest/authorize` | `pinterestURL` | Pinterest OAuth | | **Instagram** | `instagram` | `/instagram/authorize` | `instagramURL` | Instagram OAuth | | **GitHub** | `github` | `/github/authorize` | `githubURL` | GitHub OAuth | | **Facebook** | `facebook` | `/facebook/authorize` | `facebookURL` | Facebook OAuth | | **Gmail** | `gmail` | `/gmail/authorize` | `gmailURL` | Google OAuth | | **Notion** | `notion` | `/notion/authorize` | `notionURL` | Notion OAuth | ## ๐Ÿงช Testing ### Platform Coverage - โœ… **All 9 platforms** from OAuth overview now supported - โœ… **Correct URL parsing** for each platform's specific response key - โœ… **Enhanced error messages** showing expected vs actual response keys - โœ… **Proper fallback chain** for URL detection ### Test Each Platform ```bash # Test the complete implementation open onairos/test-enhanced-live-mode.html # Navigate to Universal Onboarding step # Try connecting each platform: # - YouTube (Google OAuth) # - LinkedIn (LinkedIn OAuth) # - Reddit (Reddit OAuth) # - Pinterest (Pinterest OAuth) # - Instagram (Instagram OAuth) # - GitHub (GitHub OAuth) # โœ… New # - Facebook (Facebook OAuth) # - Gmail (Google OAuth) # โœ… New # - Notion (Notion OAuth) # โœ… New ``` ## ๐Ÿ”— OAuth Flow Verification Each platform now follows the documented pattern from WEB_OAUTH_CONNECTORS_OVERVIEW.md: ### Step 1: Authorization Request ```javascript POST /{platform}/authorize { "session": { "username": "user123" } } ``` ### Step 2: Response with OAuth URL ```javascript { "{platform}URL": "https://platform.com/oauth/authorize?client_id=...&state=..." } ``` ### Step 3: OAuth Callback (Automatic) ``` GET /{platform}/callback?code=...&state=... โ†’ Exchange code for tokens โ†’ Fetch user info โ†’ Update database โ†’ Redirect to https://onairos.uk/Home ``` ## ๐ŸŽ‰ Results โœ… **Complete platform coverage** - All 9 platforms from OAuth overview โœ… **Accurate URL parsing** - Platform-specific response key mapping โœ… **Better debugging** - Enhanced error messages with expected keys โœ… **Consistent implementation** - Follows documented OAuth patterns โœ… **Removed unsupported platforms** - TikTok and Twitter not in overview The Universal Onboarding OAuth connectors now perfectly match the comprehensive WEB_OAUTH_CONNECTORS_OVERVIEW.md documentation! ๐Ÿš€