Prerequisites
- A Google Cloud Console account
- Admin access to your Google Workspace (if using domain restriction)
- Access to your application’s
.envfile
Google OAuth Setup
Access Google Cloud Console
Navigate to the Google Cloud Console and sign in with your Google account.If you don’t have a project yet, create a new one for your VPN Selfservice application.
Enable Google+ API
In your Google Cloud project:
- Go to APIs & Services > Library
- Search for “Google+ API” or “Google Identity”
- Click Enable if not already enabled
Some Google Cloud projects may have this API enabled by default.
Configure OAuth Consent Screen
Before creating credentials, configure the OAuth consent screen:
- Navigate to APIs & Services > OAuth consent screen
- Select Internal (for Google Workspace users only) or External
- Fill in the required information:
- App name: “NetBird Selfservice” or your preferred name
- User support email: Your support email
- Developer contact information
- Click Save and Continue
- Skip adding scopes (default scopes are sufficient)
- Click Save and Continue through the remaining steps
Create OAuth Client ID
Now create the OAuth credentials:
- Navigate to APIs & Services > Credentials
- Click Create Credentials > OAuth client ID
- Select Web application as the application type
- Enter a name (e.g., “VPN Selfservice Web Client”)
Configure Redirect URIs
In the OAuth client configuration, add your authorized redirect URIs:Authorized redirect URIs:Click Create when done.
Copy Credentials
After creating the OAuth client, Google will display your credentials:
- Client ID: A long string ending in
.apps.googleusercontent.com - Client Secret: A shorter secret string
Configure Environment Variables
Open your application’s Replace the values with your actual credentials from the previous step.
.env file and add the OAuth credentials:Testing Authentication
After configuring OAuth:Test Sign In
- Navigate to your application’s login page
- Click the “Sign in with Google” button
- You should be redirected to Google’s OAuth consent screen
- After granting permission, you’ll be redirected back to the application
First-time users may need to grant permission for the application to access their basic profile information.
Alternative OAuth Providers
NetBird Selfservice uses Laravel Socialite, which supports many OAuth providers:GitHub OAuth
GitHub OAuth
- Create an OAuth App in GitHub Settings > Developer settings
- Add to
.env:
- Update routes in
routes/web.phpto usegithubdriver
Microsoft Azure AD
Microsoft Azure AD
- Register an application in Azure Portal
- Install the Socialite provider:
- Configure in
.envand update authentication controller
Okta
Okta
- Create an application in your Okta admin panel
- Install the Socialite provider:
- Configure with your Okta domain and credentials
When using alternative providers, you’ll need to modify
app/Http/Controllers/Auth/GoogleController.php to support the new driver. Refer to Laravel Socialite documentation for provider-specific configuration.Troubleshooting
”Redirect URI mismatch” error
- Verify the redirect URI in your
.envfile exactly matches the one configured in Google Cloud Console - Check for trailing slashes (e.g.,
/callbackvs/callback/) - Ensure you’re using HTTPS in production
”Access blocked” error
- Check if
NETBIRD_ALLOWED_DOMAINis configured correctly - Verify the user’s email domain matches the allowed domain
- Review the OAuth consent screen configuration
”Invalid client” error
- Verify
GOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRETare correct - Check for extra spaces or line breaks in the
.envfile - Run
php artisan config:clearafter changing environment variables
Security Best Practices
Next Steps
Once OAuth is configured, proceed to:- NetBird Setup Guide - Configure NetBird API integration
- User Guide - Learn how to use the application