Overview
Social login enables customers to register and sign in using their existing social media accounts. This reduces friction in the registration process and improves user experience.Supported Providers
- Apple (Sign in with Apple)
Benefits
- Faster Registration: One-click account creation
- Reduced Friction: No password to remember
- Higher Conversion: Simplified checkout process
- Verified Emails: Most social accounts have verified emails
- Better User Data: Access to social profile information
Configuration
Controller Location
Dependencies
Social login uses Laravel Socialite:composer.json
Google Login
Step 1: Create Google OAuth App
Access Google Cloud Console
Go to Google Cloud Console
Step 2: Configure Environment
Add to.env:
.env
Step 3: Configure Services
Config is already set inconfig/services.php:
config/services.php
Facebook Login
Step 1: Create Facebook App
Access Facebook Developers
Go to Facebook Developers
Step 2: Configure Environment
.env
Step 3: Services Configuration
config/services.php
Twitter Login
Step 1: Create Twitter App
Access Twitter Developer Portal
Go to Twitter Developer Portal
Step 2: Configure Environment
.env
Step 3: Services Configuration
config/services.php
Apple Sign In
Step 1: Configure Apple Developer Account
Access Apple Developer
Go to Apple Developer Portal
Step 2: Configure Environment
Apple Sign In requires additional configuration in the package settings.Implementation Details
Redirect to Provider
app/Http/Controllers/Auth/LoginController.php
Handle Provider Callback
app/Http/Controllers/Auth/LoginController.php
Apple Callback Handler
Apple requires special handling:app/Http/Controllers/Auth/LoginController.php
Cart Transfer
When users login via social, transfer guest cart items:Mobile App Support
For mobile app social login:User Database Fields
Social login users have these additional fields:Routes Configuration
routes/web.php
Frontend Implementation
Add social login buttons to your login/register forms:Email Verification
Social login users are automatically email verified:Security Considerations
Apple Private Email Relay
Apple users can hide their email:Troubleshooting
Redirect URI Mismatch
Redirect URI Mismatch
Error:
redirect_uri_mismatchSolution:- Verify callback URL in provider settings matches exactly
- Check for HTTP vs HTTPS
- Ensure no trailing slashes
- Verify domain is authorized
Invalid Client ID
Invalid Client ID
Error:
invalid_clientSolution:- Check Client ID in
.envis correct - Verify no extra spaces in credentials
- Ensure app is published/approved
Access Denied
Access Denied
Error: User cancels authorizationSolution:
- Handle exception gracefully
- Redirect to login with message
- Don’t force social login
Email Already Exists
Email Already Exists
Issue: User already registered with emailSolution:
- Link social account to existing email
- Update provider_id and access_token
- Implemented in code above
Enable/Disable Social Login
Configure in admin panel:- Navigate to Settings → Social Login
- Enable/disable each provider
- Enter API credentials
- Save configuration
Testing
Development Testing
- Use localhost redirect URLs during development
- Test with real social accounts
- Verify cart transfer works
- Test user creation and login
- Check email verification status
Production Checklist
Best Practices
- Offer traditional email/password option alongside social login
- Clearly communicate data usage in privacy policy
- Handle account linking gracefully
- Support account deletion per GDPR
- Test across different devices and browsers
- Monitor OAuth error rates
- Keep Socialite package updated
Related Documentation
SMS/OTP Integration
Configure SMS and OTP verification
User Management
Manage user accounts