|
| 1 | +# Facebook Authentication Setup |
| 2 | + |
| 3 | +This guide explains how to set up Facebook authentication in the Supabase Examples app. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +1. A Facebook Developer account |
| 8 | +2. A Facebook App created in the Facebook Developer Console |
| 9 | +3. Supabase project with Facebook OAuth configured |
| 10 | + |
| 11 | +## Setup Steps |
| 12 | + |
| 13 | +### 1. Facebook Developer Console Configuration |
| 14 | + |
| 15 | +1. Go to [Facebook Developers](https://developers.facebook.com/) |
| 16 | +2. Create a new app or use an existing one |
| 17 | +3. Add "Facebook Login" product to your app |
| 18 | +4. Configure your OAuth redirect URIs in Facebook Login settings: |
| 19 | + - Add your Supabase project's Facebook OAuth callback URL |
| 20 | + - Format: `https://[your-project-ref].supabase.co/auth/v1/callback` |
| 21 | + |
| 22 | +### 2. Supabase Configuration |
| 23 | + |
| 24 | +1. Go to your Supabase project dashboard |
| 25 | +2. Navigate to Authentication > Providers |
| 26 | +3. Enable Facebook provider |
| 27 | +4. Enter your Facebook App ID and App Secret |
| 28 | +5. Configure the redirect URL if needed |
| 29 | + |
| 30 | +### 3. Flutter App Configuration |
| 31 | + |
| 32 | +#### Android Configuration |
| 33 | + |
| 34 | +The following files have been configured for you: |
| 35 | + |
| 36 | +1. **AndroidManifest.xml** - Contains Facebook SDK configuration |
| 37 | +2. **strings.xml** - Contains placeholder values for Facebook credentials |
| 38 | + |
| 39 | +You need to update the following values in `android/app/src/main/res/values/strings.xml`: |
| 40 | + |
| 41 | +```xml |
| 42 | +<string name="facebook_app_id">YOUR_ACTUAL_FACEBOOK_APP_ID</string> |
| 43 | +<string name="facebook_client_token">YOUR_ACTUAL_FACEBOOK_CLIENT_TOKEN</string> |
| 44 | +<string name="fb_login_protocol_scheme">fbYOUR_ACTUAL_FACEBOOK_APP_ID</string> |
| 45 | +``` |
| 46 | + |
| 47 | +#### iOS Configuration |
| 48 | + |
| 49 | +The following files have been configured for you: |
| 50 | + |
| 51 | +1. **Info.plist** - Contains Facebook SDK configuration |
| 52 | + |
| 53 | +You need to update the following values in `ios/Runner/Info.plist`: |
| 54 | + |
| 55 | +```xml |
| 56 | +<key>FacebookAppID</key> |
| 57 | +<string>YOUR_ACTUAL_FACEBOOK_APP_ID</string> |
| 58 | +<key>FacebookClientToken</key> |
| 59 | +<string>YOUR_ACTUAL_FACEBOOK_CLIENT_TOKEN</string> |
| 60 | +``` |
| 61 | + |
| 62 | +And update the URL scheme: |
| 63 | +```xml |
| 64 | +<string>fbYOUR_ACTUAL_FACEBOOK_APP_ID</string> |
| 65 | +``` |
| 66 | + |
| 67 | +## Getting Your Facebook Credentials |
| 68 | + |
| 69 | +### App ID |
| 70 | +1. Go to Facebook Developers Console |
| 71 | +2. Select your app |
| 72 | +3. Go to Settings > Basic |
| 73 | +4. Copy the "App ID" |
| 74 | + |
| 75 | +### Client Token |
| 76 | +1. In the same Basic settings page |
| 77 | +2. Copy the "Client Token" |
| 78 | +3. If you don't see it, you may need to generate one |
| 79 | + |
| 80 | +## Testing |
| 81 | + |
| 82 | +1. Replace all placeholder values with your actual Facebook credentials |
| 83 | +2. Run `flutter pub get` to install dependencies |
| 84 | +3. Run the app and test the "Continue with Facebook" button |
| 85 | +4. Ensure your Facebook app is configured to allow the bundle ID/package name of your Flutter app |
| 86 | + |
| 87 | +## Troubleshooting |
| 88 | + |
| 89 | +- **Android**: Make sure your package name in `android/app/build.gradle` matches what's configured in Facebook |
| 90 | +- **iOS**: Make sure your bundle identifier matches what's configured in Facebook |
| 91 | +- **Both platforms**: Ensure your Facebook app is not in "Development Mode" if testing with non-developer accounts |
| 92 | +- Check that your Supabase Facebook OAuth configuration matches your Facebook app settings |
| 93 | + |
| 94 | +## Security Notes |
| 95 | + |
| 96 | +- Never commit real Facebook credentials to version control |
| 97 | +- Consider using environment variables or secure configuration management |
| 98 | +- Regularly rotate your Facebook Client Token |
0 commit comments