Social Login Setup
Configure Google, Facebook and Twitter OAuth authentication to allow users to sign in with their social accounts.
Social login is optional. Users can always register and log in with email/password. Enable social login to provide a faster signup experience.
Supported Providers
CoinTrail supports the following social login providers:
Allow users to sign in with their Google account. Most popular and recommended option.
Allow users to sign in with their Facebook account. Requires a Facebook App.
Twitter/X
Allow users to sign in with their Twitter/X account. Requires a Twitter Developer App.
Enabling/Disabling Social Login
You can enable or disable social login globally from the admin panel:
Access Feature Settings
- Go to Admin Panel > Settings > Features
- Find the Enable Social Login toggle
- Toggle it ON to enable social login, or OFF to disable
- Click Save
Feature Settings - Enable or disable social login for the entire site
When social login is disabled, the social login buttons will be completely hidden from the login and registration pages. Users will only see the email/password form.
Google Login Setup
Google is the most popular social login option. Most users have a Google account and are familiar with Google's sign-in flow.
Create a Google Cloud Project
- Go to Google Cloud Console
- Click Select a project at the top, then New Project
- Enter a project name (e.g., "CoinTrail")
- Click Create
Configure OAuth Consent Screen
- In the Google Cloud Console, go to APIs & Services > OAuth consent screen
- Select External user type (unless you're using Google Workspace)
- Click Create
- Fill in the required fields:
- App name: Your site name (e.g., "CoinTrail")
- User support email: Your email
- Developer contact email: Your email
- Click Save and Continue
- On the Scopes page, click Add or Remove Scopes
- Select email and profile scopes
- Click Save and Continue
Create OAuth Credentials
- Go to APIs & Services > Credentials
- Click + Create Credentials at the top
- Select OAuth client ID
- Choose Web application as the application type
- Enter a name (e.g., "CoinTrail Web")
- Under Authorized JavaScript origins, add:
https://yourdomain.com
- Under Authorized redirect URIs, add:
https://yourdomain.com/user/login/google/callback
- Click Create
Get Client ID and Secret
- After creating the credentials, a popup will show your Client ID and Client Secret
- Copy both values (you can also find them later in Credentials > OAuth 2.0 Client IDs)
Publish the App (Important!)
- Go back to APIs & Services > OAuth consent screen
- Under "Publishing status", click Publish App
- Confirm by clicking Confirm
While in "Testing" mode, only users you've added as test users can use Google login. You must publish the app for all users to be able to sign in.
Configure CoinTrail
Option 1: Using .env file
Add the following to your .env file:
# Google OAuth
GOOGLE_CLIENT_ID=your_client_id_here
GOOGLE_CLIENT_SECRET=your_client_secret_here
GOOGLE_REDIRECT_URL=https://yourdomain.com
Option 2: Using Admin Panel
You can also configure Google OAuth from the admin panel:
- Go to Admin Panel > Settings > Third Party
- Find the Social Login OAuth section
- Enter your Google Client ID and Client Secret
- Click Save
Facebook Login Setup
Create a Facebook App
- Go to Facebook Developers
- Click My Apps in the top right corner
- Click Create App
- Select "Consumer" as the app type
- Enter your app name (e.g., "CoinTrail Login")
- Click Create App
Configure Facebook Login Product
- In your app dashboard, click Add Product
- Find Facebook Login and click Set Up
- Select Web as the platform
- Enter your website URL:
https://yourdomain.com - Click Save
Configure OAuth Settings
- Go to Facebook Login > Settings
- In Valid OAuth Redirect URIs, add:
https://yourdomain.com/user/login/facebook/callback
- Enable Login with the JavaScript SDK
- Click Save Changes
Get App Credentials
- Go to Settings > Basic
- Copy your App ID and App Secret
- Fill in required fields (Privacy Policy URL, Terms of Service URL)
- Set App Mode to Live (when ready for production)
Configure CoinTrail
Add the following to your .env file:
# Facebook OAuth
FB_CLIENT_ID=your_app_id_here
FB_SECRET_ID=your_app_secret_here
FB_REDIRECT_URL=https://yourdomain.com
The FB_REDIRECT_URL must match your site URL exactly (including https). Do not include a trailing slash.
Twitter/X Login Setup
Create a Twitter Developer Account
- Go to Twitter Developer Portal
- Sign in with your Twitter account
- Apply for a developer account if you haven't already
- Complete the application form describing your use case
Twitter developer account approval may take a few hours to a few days. You'll receive an email when approved.
Create a Twitter App
- In the Developer Portal, go to Projects & Apps
- Click + Add App or Create App
- Enter your app name (e.g., "CoinTrail")
- Click Complete
Configure User Authentication
- Go to your app's Settings tab
- Scroll to User authentication settings
- Click Set up
- Configure the following:
- App permissions: Read
- Type of App: Web App, Automated App or Bot
- Callback URI:
https://yourdomain.com/user/login/twitter/callback
- Add your Website URL:
https://yourdomain.com - Click Save
Get API Keys
- Go to Keys and Tokens tab
- Under Consumer Keys, copy:
- API Key (Client ID)
- API Key Secret (Client Secret)
Configure CoinTrail
Add the following to your .env file:
# Twitter/X OAuth
TW_CLIENT_ID=your_api_key_here
TW_SECRET_ID=your_api_key_secret_here
TW_REDIRECT_URL=https://yourdomain.com
Complete .env Configuration
Here's a complete example of all social login environment variables:
# ================================
# Social Login Configuration
# ================================
# Google OAuth
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
GOOGLE_REDIRECT_URL=https://yourdomain.com
# Facebook OAuth
FB_CLIENT_ID=your_facebook_app_id
FB_SECRET_ID=your_facebook_app_secret
FB_REDIRECT_URL=https://yourdomain.com
# Twitter/X OAuth
TW_CLIENT_ID=your_twitter_api_key
TW_SECRET_ID=your_twitter_api_secret
TW_REDIRECT_URL=https://yourdomain.com
Testing Social Login
Before going live, test your social login integration:
- Open an incognito/private browser window
- Go to your site's login page
- Click the Google, Facebook or Twitter login button
- You should be redirected to the provider's authorization page
- After authorizing, you should be redirected back and logged in
Troubleshooting
Common Issues
| Issue | Solution |
|---|---|
| "Redirect URI mismatch" error | Ensure the callback URL in your provider settings exactly matches your site URL (including https and no trailing slash). |
| Google: "Access blocked: This app's request is invalid" | Make sure the redirect URI in Google Cloud Console matches exactly: https://yourdomain.com/user/login/google/callback |
| Google: Only test users can sign in | Go to OAuth consent screen and click "Publish App" to move from Testing to Production mode. |
| "App not set up" error on Facebook | Make sure your Facebook app is in Live mode (not Development mode) and all required fields are filled. |
| Twitter login fails silently | Check that your Twitter app has the correct callback URL and that User Authentication is properly configured. |
| Social login buttons not showing | Verify that social login is enabled in Admin Panel > Settings > Features and that the .env variables are correctly set. |
| "Invalid API key" error | Double-check that you've copied the correct API keys to your .env file without any extra spaces. |
If you're having issues, temporarily set APP_DEBUG=true in your .env file to see detailed error messages. Remember to set it back to false for production.