OAuth2 Authentication
Login to Odoo via Google, Facebook, GitHub and other OAuth2 providers
Overview
The auth_oauth module allows users to login to Odoo using OAuth2 accounts (Google, Facebook, GitHub) instead of separate Odoo passwords.
Reduces password management burden, increases security and improves user experience with Single Sign-On.
Key Features
Key points
• Login via Google, Facebook, GitHub, Microsoft - No Odoo password needed
• Auto-create users - Users created automatically from OAuth provider info
• OAuth token management - Store and refresh access tokens automatically
• Multiple providers - Support multiple OAuth providers simultaneously
• Integrate with auth_signup - Combine with self-registration
• Custom buttons - Customize login button labels and icons
Configure Google OAuth
Steps
1. Create OAuth App on Google Cloud Console: Go to console.cloud.google.com, create new project
2. Go to APIs & Services → Credentials, click Create Credentials → OAuth 2.0 Client ID
3. Select Application type: Web application, name it "Odoo"
4. Add Authorized redirect URIs: https://your-odoo.com/auth_oauth/signin
5. Copy Client ID and Client Secret
6. In Odoo: Go to Settings → General Settings → OAuth Authentication
7. Enable "Allow users to sign in with Google"
8. Paste Client ID from Google Console
9. Click Save
Detailed OAuth Provider Configuration
| Fields | Trường dữ liệu | Description |
|---|---|---|
| Provider name | Display name of provider | |
| Client ID | [Client ID from Google] | OAuth application ID |
| Authorization URL | https://accounts.google.com/o/oauth2/auth | Authentication URL |
| UserInfo URL | https://www.googleapis.com/oauth2/v1/userinfo | User info retrieval URL |
| Scope | openid profile email | Requested access permissions |
| Allowed | Yes | Allow using this provider |
| Login button label | Sign in with Google | Login button text |
Other Provider Configurations
Popular OAuth providers
| Provider | Authorization URL | UserInfo URL | Scope |
|---|---|---|---|
| https://www.facebook.com/v12.0/dialog/oauth | https://graph.facebook.com/me?fields=id,name,email | ||
| GitHub | https://github.com/login/oauth/authorize | https://api.github.com/user | user:email |
| Microsoft | https://login.microsoftonline.com/common/oauth2/v2.0/authorize | https://graph.microsoft.com/v1.0/me | openid profile email |
OAuth Login Workflow
Steps
1. User clicks "Sign in with Google" button on Odoo login page
2. Odoo redirects user to Google for authentication
3. User logs into Google and grants Odoo access to basic info
4. Google redirects back to Odoo with authorization code
5. Odoo exchanges code for access token from Google
6. Odoo retrieves user info (email, name) from Google
7. If user does not exist: Create new user with Google info
8. User is logged into Odoo
Troubleshooting
Common Errors
| Error | Cause | Solution |
|---|---|---|
| Redirect URI mismatch | Redirect URI in Odoo does not match Google Console | Copy exact Redirect URI from Odoo to Google Console |
| Invalid client | Wrong Client ID or Client Secret | Verify Client ID/Secret, create new if needed |
| Access denied | User denied permission | Guide user to allow Odoo access to email and profile |
| User not created | Email already exists with different provider | Link OAuth to existing user or use different email |
| Token expired | Access token expired | Odoo auto-refreshes token, if error persists re-login |