Skip to content

Instantly share code, notes, and snippets.

@macagua
Last active March 30, 2022 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save macagua/4aaec47288f33628dee77e060aa8ca8e to your computer and use it in GitHub Desktop.
Save macagua/4aaec47288f33628dee77e060aa8ca8e to your computer and use it in GitHub Desktop.
Odoo and Facebook

Odoo and Facebook Login

UPDATED: Wed 30 Mar 2022 06:14:30 PM -04.

Configure to allow user to sign up using OAuth

Tested

  • Odoo 13 CE.

OAuth providers

First activate your Developer mode then you follow the steps, Then install the auth_oauth module

Facebook Login

More info: https://developers.facebook.com/products/facebook-login/

  1. Create an account at https://developers.facebook.com
  2. Create an App, https://developers.facebook.com -> My apps -> Create app

2.1. Select the App Type as Consumer (Connect consumer permissions and products, such as Facebook login and basic Instagram viewing, to your app.)"

2.2. Select the App Details > Name to show enter Odoo App Auth -> Create app.

2.3. Add a product to you app and select Facebook Login -> Configure -> Web.

  1. Tell us about your website -> Website URL "https://YOURDOMAIN/" -> Save -> Next

3.1. Configure the Facebook SDK for JavaScript -> Copy and Paste -> Next

Adapt the original source code needed for the Facebook SDK:

<!-- Facebook SDK - START -->
<script>
    window.fbAsyncInit = function() {
        FB.init({
            appId      : '{your-app-id}',
            cookie     : true,
            xfbml      : true,
            version    : '{api-version}'
        });
        FB.AppEvents.logPageView();   
    };
    (function(d, s, id){
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) {return;}
        js = d.createElement(s); js.id = id;
        js.src = "https://connect.facebook.net/en_US/sdk.js";
        fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
</script>
<!-- Facebook SDK - END -->

Please, changes the values of appId and version on the method FB.init() used to initialize and setup the SDK

Now go to the Odoo Website Editor->Customize->HTML/CSS/JS Editor->Web Layoutthen Copy and Paste the new source code at before the finish the header element, then click onSave->Closebuttons **Note:** *There is no need to download or install any separate files to use the Facebook SDK for JavaScript. You just need to include a short piece of JavaScript code in your HTML that will asynchronously load the SDK on your pages. Asynchronous loading of the SDK will not block loading of other elements on the page.* 4. Make sure theValid OAuth Redirect URIsis set to *https://YOURDOMAIN/auth_oauth/signin* under "https://developers.facebook.com -> YOURAPP ->Products->Facebook Login->Settings->Client OAuth Settingsand click on "Save changes" button. 5. Go toApp Review->Permissions and Features->public_profile->Request Advanced Access, then mark the checkbox item (I agree that any data I receive throughpublic_profilewill be used in accordance with the allowed usage.) and click onConfirmbutton. 6. For finish you need change the App Mode fromDevelopmenttoActiveclicking on checkbox switch. 7. Get the Facebook app-id and set to yourOdoo->Settings->Users and companies->OAuth Providers->Facebook Graph->Edit-> enter theClient IDand mark the checkbox itemEnabled-> clickSavebutton. 8. Now got to your login page *https://YOURDOMAIN/web/login* and clic onLogin with Facebook``.

Errors

Facebook Login is currently unavailable for this app as we are updating additional details for this app. Please try again later. https://stackoverflow.com/a/69486468/1439705

Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment