OAuth2 Authentication

Login to Odoo via Google, Facebook, GitHub and other OAuth2 providers

OAuth2
Google
Facebook
GitHub
Microsoft
SSO

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

FieldsTrường dữ liệuDescription
Provider nameGoogleDisplay name of provider
Client ID[Client ID from Google]OAuth application ID
Authorization URLhttps://accounts.google.com/o/oauth2/authAuthentication URL
UserInfo URLhttps://www.googleapis.com/oauth2/v1/userinfoUser info retrieval URL
Scopeopenid profile emailRequested access permissions
AllowedYesAllow using this provider
Login button labelSign in with GoogleLogin button text

Other Provider Configurations

Popular OAuth providers

ProviderAuthorization URLUserInfo URLScope
Facebookhttps://www.facebook.com/v12.0/dialog/oauthhttps://graph.facebook.com/me?fields=id,name,emailemail
GitHubhttps://github.com/login/oauth/authorizehttps://api.github.com/useruser:email
Microsofthttps://login.microsoftonline.com/common/oauth2/v2.0/authorizehttps://graph.microsoft.com/v1.0/meopenid 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

ErrorCauseSolution
Redirect URI mismatchRedirect URI in Odoo does not match Google ConsoleCopy exact Redirect URI from Odoo to Google Console
Invalid clientWrong Client ID or Client SecretVerify Client ID/Secret, create new if needed
Access deniedUser denied permissionGuide user to allow Odoo access to email and profile
User not createdEmail already exists with different providerLink OAuth to existing user or use different email
Token expiredAccess token expiredOdoo auto-refreshes token, if error persists re-login