Single Sign-On is one of the highest-impact changes you can make to a Moodle deployment. When faculty and students can log in with their existing Google or Microsoft accounts, support tickets drop, adoption increases, and the platform feels like part of the institution rather than a separate system.
Here's exactly how I configured OAuth2 SSO at IIT Patna for 10,000+ users — including every pitfall I hit along the way.
Step 1 — Create the OAuth2 App
Before touching Moodle, you need to create an OAuth2 application in your identity provider. For Google:
- Go to Google Cloud Console → APIs & Services → Credentials
- Create a new OAuth 2.0 Client ID → Web Application
- Add your Moodle URL as an Authorised redirect URI:
https://yourmoodle.com/admin/oauth2callback.php - Note your Client ID and Client Secret
Common mistake: adding http:// instead of https:// in the redirect URI. Moodle requires HTTPS for OAuth2.
Step 2 — Configure Moodle OAuth2 Issuer
In Moodle, navigate to Site Administration → Server → OAuth 2 services. Click "Google" to use the built-in template, or create a custom issuer for Microsoft or other providers.
Enter your Client ID and Client Secret. Set the login page display to show the SSO button prominently. Test the connection before proceeding — the built-in test will catch redirect URI mismatches immediately.
Step 3 — Enable the Auth Plugin
Go to Site Administration → Plugins → Authentication → Manage authentication. Enable "OAuth 2" in the list. Set it as the default auth method if you want all new accounts created via SSO.
Step 4 — Account Linking Strategy
This is where most deployments get complicated. You have three options:
- New accounts only — SSO creates new Moodle accounts. Existing users must link manually.
- Email matching — SSO automatically links to existing Moodle accounts with the same email. Best for institutions with existing user bases.
- Username matching — Links based on username. Only works if your Moodle usernames match your identity provider's usernames.
At IIT Patna, we used email matching — it allowed the 5,000+ existing students to immediately use SSO without any manual linking step.
Step 5 — Testing & Rollout
Always test in a staging environment first. Create a test account in your identity provider and verify the full flow — login, account creation, and role assignment. Then do a phased rollout: admins first, then faculty, then students.
Keep manual username/password login enabled during rollout. Disable it only after confirming SSO works for all user types.
Common Issues
- Redirect URI mismatch — Double-check the exact URL including trailing slashes
- Duplicate accounts — Happens when email matching is off and users log in with SSO after having a manual account. Fix with the account linking tool.
- Scope errors — Ensure your OAuth2 app requests the correct scopes: email, profile, openid