π― Goal
Make Google login work using only .env:
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_REDIRECT_URI=π 1. Create OAuth Credentials
Go to Google Cloud Console
Steps:
- Create/select a project
- Go to: APIs & Services β OAuth consent screen
βοΈ Configure Consent Screen
- Choose: External
- Fill required:
- App name
- Support email
- Developer email
Add scopes:
emailprofile
β Add Test Users (IMPORTANT)
Scroll down β Test Users
Click:
+ ADD USERS
Add:
[email protected]
[email protected]
π Only these users can log in while testing
π 2. Create OAuth Client ID
Go to:
π APIs & Services β Credentials
Click:
+ CREATE CREDENTIALS β OAuth Client ID
Select:
- Web Application
Add Redirect URI:
http://sprintly.test/auth/google/callback
β οΈ Must match Laravel exactly
π¦ 3. Put Credentials in .env
GOOGLE_CLIENT_ID=xxxx.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=xxxx
GOOGLE_REDIRECT_URI=http://yoursite.com/auth/google/callbackπ 4. Apply Changes
php artisan config:clear
php artisan cache:clear
π§ͺ Testing vs Production
π§ͺ Testing Mode (Default)
- Only Test Users can log in
- No verification needed
π Use for:
- development
- demo
- client testing
π Publish App (Production)
- Anyone can log in
- May require Google verification
π Use when:
- app is fully live
- real users need access
π§ Decision Rule
- Few users β Stay in Testing
- Public system β Publish later
β οΈ Common Errors
β redirect_uri_mismatch
β .env and Google Console donβt match exactly
β invalid_client
β wrong client ID / secret
β This app isnβt verified
β user not in Test Users OR app not published
β‘ Local vs Production
Local:
GOOGLE_REDIRECT_URI=http://sprintly.test/auth/google/callback
Production:
GOOGLE_REDIRECT_URI=https://yourdomain.com/auth/google/callback
π Add BOTH in Google Console
π§ Final Mental Model
- Consent Screen β user-facing setup
- Client ID β app credentials
- Test Users β who can log in (testing mode)
- Publish App β open to public
β TL;DR
- Setup consent screen
- Add test users
- Create OAuth Client ID
- Paste in
.env - Match redirect exactly