Skip to content

Instantly share code, notes, and snippets.

@macagua
Last active June 5, 2024 06:30
Show Gist options
  • 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 Layout then Copy and Paste the new source code at before the finish the header element, then click on Save -> Close buttons

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.

  1. Make sure the Valid OAuth Redirect URIs is set to https://YOURDOMAIN/auth_oauth/signin under "https://developers.facebook.com -> YOURAPP -> Products -> Facebook Login -> Settings -> Client OAuth Settings and click on "Save changes" button.
  2. Go to App Review -> Permissions and Features -> public_profile -> Request Advanced Access, then mark the checkbox item (I agree that any data I receive through public_profile will be used in accordance with the allowed usage.) and click on Confirm button.
  3. For finish you need change the App Mode from Development to Active clicking on checkbox switch.
  4. Get the Facebook app-id and set to your Odoo -> Settings -> Users and companies -> OAuth Providers -> Facebook Graph -> Edit -> enter the Client ID and mark the checkbox item Enabled -> click Save button.
  5. Now got to your login page https://YOURDOMAIN/web/login and clic on Login 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