In Odoo, each user will have a username and a password. They can sign into Odoo with this username and password. Other than this, Odoo provides options for the users to sign in with other accounts such as google or facebook.
For enabling this feature, first, we have to make sure that the incoming and outgoing mail servers are correctly configured. This can be done under the 'Email' menu in the settings. It is already discussed in another blog. After it is done, go to Settings -> General Settings and enable the 'Authentication' option.
Apply the changes and you can see a new option has appeared.
Enable the 'Authentication' option to allow users to sign in with Google. Once this option is enabled, we can see a field to enter the google client id. If you do not have a client id, you have to obtain one first.
You can enable the 'Show Tutorial' option to see a demo of how to get a client id from google.
The process of getting a client id is as follows. First, go to “https://console.developers.google.com/” and create a new project. After this, under the API manager, click on Credentials and go to OAuth Consent Screen. Fill the product name and save it.
After it is done, click on Create Credentials and select the option, OAuth Client ID, then select the Web application from the list.
Fill the Authorized redirect URIs field, like, “http://your_domain_name/auth_oauth/signin”. After this, you will get your client ID. When providing the URI, it is not allowed to enter raw IP address. i.e, like, http://0.0.0.0:8082/auth_oauth/signin. We have to provide a proper domain name or IP address, it should end like .com or .org.
Enter this client ID in Odoo (Settings -> General Settings -> Google Integration -> Google client id).
Now under Settings -> Users, a new menu 'Oauth Providers' will be appeared. Under this menu, we can see the providers list. Now open odoo.com accounts and uncheck the 'Allowed' field. Enable the 'Allowed' field for Google Oauth2. Once it is done, we can create new users and provide the email address. This email address should be the user’s Google account. Under the 'Oauth' tab, select the OAuth provider as Google Oauth2 and save the record.
Now if we go to the login page, we can find a new option for the users to sign in with Google accounts.
We will be redirected to the google account sign-in page by clicking on the 'Login with Google' link. From here, we can sign into our google account and after we have signed in, we will be redirected to Odoo.
Use Facebook to sign in :
If we need to use Facebook to sign in to Odoo instead of Google, we need to follow these steps. First, we need to obtain a client id from Facebook. For this, go to https://developers.facebook.com/apps and sign in with your Facebook account. We can see our apps here. Add a new app from here. If you are doing this for the first time, then click on the register now button.
Provide a name and email address for the app and save it. After it is created, we can see the created app and its id.
Here, ‘Odoo test’ is my app name. Click on the settings to open the settings related to our app. Here we can provide the domain of our Odoo and the complete URL. One thing we have to note is, the domain we are providing should be same as the domain we use in Odoo. Save the changes and copy the app id. Now we can go to our Odoo and open the facebook graph from the OAuth providers menu under settings. Fill the client id field with the app id and tick the field ‘Allowed’.
Now we can see an option to sign in with facebook on our login page. When we click on that link, we will be redirected to a page where we can sign in to our Facebook and after signing in, we will be redirected to Odoo.