🔐 How I Enabled Google & Microsoft OAuth2 Login in Moodle (Step-by-Step Guide)
Posted by Prateek Sharma – July 2025
Many institutions want secure, single-click login for their Moodle platform using Google or Microsoft accounts. In this guide, I’ll share how I configured OAuth2 login (SSO) for both Google and Microsoft — tested on Moodle 4.x running on Linux.
Step 1: Enable OAuth2 Service in Moodle
- Login as Admin → Site Administration
- Go to
Server → OAuth 2 Services
- Click Google or Microsoft to configure
Step 2: Create Credentials (Google Console or Azure)
For Google:
- Go to Google API Console
- Create a new OAuth 2.0 Client ID
- Authorized Redirect URI:
https://yourmoodlesite.com/admin/oauth2callback.php
For Microsoft:
- Visit Azure Portal
- Register a new App in Azure Active Directory
- Redirect URI: same as above
Step 3: Add Client ID and Secret in Moodle
Once credentials are ready:
- Go back to Moodle → OAuth2 Services
- Edit the provider → Paste Client ID and Client Secret
- Save and verify connection (token should be valid)
Step 4: Enable as Login Option
Go to:
Site admin → Plugins → Authentication → Manage authentication
- Enable OAuth2 and set as visible
Step 5: Test It
Visit your login page. You should now see buttons for:
- Login with Google
- Login with Microsoft
Optional Tips
- Use a custom logo/icon for Google & Microsoft buttons
- Works even for Moodle on localhost or internal IP (if you add public domain + SSL)
- You can restrict login to specific domains (e.g., @iitp.ac.in)
Conclusion
OAuth2 login improves user experience and reduces forgotten password issues. I’ve used it successfully on both Oracle Cloud and in-house Linux servers for IIT-based Moodle platforms.
Need help setting this up? Contact me here or visit MoodleSupport.in for full deployment services.
←