Skip to main content

Logging in with Facebook

Members log in with their Facebook account. Setting it up takes about fifteen minutes: an app in Meta for Developers, two addresses and the email permission in it, its App ID and App Secret in Poly Community, and a test. Until Meta has reviewed the app and you publish it, only people with a role on the app can log in with it, so plan for the review too (step 9).

You need:

  • A Facebook account registered as a developer at Meta for Developers.
  • Your site on https.
  • To publish the app: a privacy policy page on your site, a square icon for the app of 1024 by 1024 pixels, a business portfolio at Meta that Meta has verified (you can make one, but it needs a registered business, its documents, and its legal name on your website), and a few days for the review.

How single sign-on works for every provider, and what each setting does, is on Single sign-on.

1. Copy the two addresses​

  1. In WordPress, go to Poly Community → Settings → Services → Single sign-on.
  2. Press Set up on the Facebook row.
  3. The dialog shows two addresses to copy:
    • Valid OAuth Redirect URI, such as https://example.com/wp-json/wordplus/v1/sso/back, where Facebook sends members back.
    • Data deletion callback URL, such as https://example.com/wp-json/wordplus/v1/sso/facebook/deletion, where Facebook sends a request when someone asks it to delete what your site has of them.
The Facebook dialog: Make the app, the Valid OAuth Redirect URI and the Data deletion callback URL to copy, App ID, App Secret kept, and Let new people join with it
Settings → Services → Single sign-on → Facebook

Leave the dialog open. Make the app in it opens Meta for Developers.

2. Create the app​

  1. In Meta for Developers, press Create App.

  2. App details: give the app the name of your community, which people see when they log in, and an email address Meta can reach you at. Press Next.

    Create an app, App details: App name and App contact email
    Meta for Developers → Create App → App details
  3. Use cases: choose Authenticate and request data from users with Facebook Login, then Next.

    The use case Authenticate and request data from users with Facebook Login, chosen
    Create App → Use cases
  4. Business: choose your verified business portfolio if you have one. Otherwise choose not to connect one yet: you can connect it later, before the review. Press Next.

  5. Requirements lists what Meta asks before the app can be published: business verification and App Review. Nothing is needed for the test. Press Next.

    Publishing requirements: Business verification and App Review, each required for 1 use case
    Create App → Requirements
  6. Overview: press Create app. The dashboard of the app opens, in development mode.

3. Add the email permission​

A new app can read the public profile only. Without the email permission, Facebook does not give your site the address of the person.

  1. On the dashboard, press Customize the Authenticate and request data from users with Facebook Login use case.
  2. Under Permissions and features, press Add beside email. It now says Ready for testing, as public_profile does.
The email permission, Ready for testing
Use cases → Customize → Permissions and features

4. Enter the redirect URI​

  1. In the same use case, open Settings.
  2. Under Client OAuth settings, paste the Valid OAuth Redirect URI in Valid OAuth Redirect URIs and press Enter, so that it shows as an entry with an x beside it. Pasted text left in the field is not saved.
  3. Press Save changes at the bottom of the page.

Leave Client OAuth login, Web OAuth login and Enforce HTTPS on. Use Strict Mode for redirect URIs is always on, so the address has to match exactly.

Client OAuth settings: Client OAuth login and Web OAuth login on, Enforce HTTPS and Strict Mode on, and the redirect URI of the site in Valid OAuth Redirect URIs
Use cases → Customize → Settings

5. Fill in the basic settings​

Go to App settings → Basic.

  1. Copy the App ID. Press Show beside App secret and copy it too. Meta asks for your Facebook password first.

    App settings, Basic: App ID, App secret with Show, Display name, Namespace, App domains and Contact email
    App settings → Basic
  2. Under User data deletion, choose Data deletion callback URL and paste the Data deletion callback URL from the dialog.

    User data deletion: Data deletion callback URL chosen, with the address of the site
    App settings → Basic → User data deletion
  3. Choose a Category. For publishing later, add the Privacy policy URL and the App icon (1024 by 1024 pixels) when you have them (step 9).

  4. Press Save changes.

What the data deletion callback does​

Meta asks every app that reads data of people to let them have it deleted. When someone asks Facebook to delete what your site has of them, Facebook sends a request signed with your App Secret. Poly Community checks the signature, removes the link between their Facebook account and their account on your site, and answers with a confirmation code and a page where they can see that it was done. Their account on your site stays, and they can still log in another way.

6. Enter the keys​

  1. Back in the dialog in WordPress, paste the App ID and the App Secret.
  2. Decide who may use it with Let new people join with it. See Let new people join with it.
  3. Press Save the provider. The Facebook row now says Set up and Off: members do not see it yet.

7. Try it​

While the app is in development mode, only people with a role on the app (its administrators, developers and testers) can log in through it. You made it, so you can. Turn the button on for the test, and off again after it until you send the app to review (step 8), as everyone else would get an error from Facebook.

  1. Press Turn it on on the Facebook row, which opens Settings → Joining → Logging in. Turn Facebook on with its switch, and press Save changes.

  2. In a private window, open the login page of your site and press Continue with Facebook.

    The login form of the community with Continue with Google, Microsoft, Apple and Facebook under it
    The login form, with Google, Microsoft, Apple and Facebook on
  3. Log in to Facebook. The first time, Facebook asks to share your name, profile picture and email address with the app. Press Continue as with your name. The note about Login Review is for you as its developer: people do not see it once the app is published.

    Facebook asks to share the name and profile picture and the email address with the app, with Continue and Cancel
    Facebook, the first time someone logs in to the app
  4. You are back on your site. A member whose Facebook account is connected is logged in. Someone new is on the sign-up form. When an account here already has the email address of the Facebook account, the login form asks to log in to it once, and Facebook is connected from then on.

8. Turn it on for everyone​

Turn Facebook on when you send the app to review (step 9), and leave it on from then. Press Turn it on on the Facebook row and turn Facebook on in Settings → Joining → Logging in. Continue with Facebook then shows on the login form of the community and on the WordPress login screen, in the blue of Facebook. With Let new people join with it on, it shows on the sign-up forms too.

Until the app is published, Facebook turns away everyone without a role on the app who presses it. So send the app to review only once everything else in step 9 is ready, and the button shows for those few days only.

9. Publish the app​

Meta reviews every app made in its current dashboard before it can be published, even one that only asks for the public profile and the email address. Until then, add the people who should try it as testers under App roles → Roles.

  1. App settings → Basic needs the Privacy policy URL, the App icon, the Category and the User data deletion callback. Until they are all there, a banner at its top says Currently ineligible for submission and lists what is missing.

    • The App icon is a square picture of 1024 by 1024 pixels. After you choose the file, Meta asks where to crop it: drag the corners of the white square out to the edges to keep the whole picture.

    • The Terms of Service URL is optional. Add the address of your terms page if you have one.

    • At the bottom, press Add platform, choose Website, enter the address of your site as Site URL, and press Save changes. Under it, Add or update instructions holds what the reviewers read: where the login is (the address of your login page), how to try it, whether Facebook Login is used (Yes), and any codes or limits by country. The App Review form takes its reviewer instructions from here. For how to try it, you can start from this text, with your own address:

      1. Open https://example.com/login/, the login page of the community.
      2. Press Continue with Facebook under the login form.
      3. Log in to Facebook with a test user and allow access to the name, profile picture and email address.
      4. Facebook sends you back to the site. Someone new lands on the sign-up form with the name and email address from Facebook filled in. Before the account is made, the site emails a code to that address to confirm it, because Facebook does not say whether an address is confirmed. A member whose Facebook account is already connected is logged in at once.

      How Facebook Login is used: only to log in and to sign up. public_profile gives the Facebook user ID, which the site keeps to recognise the member at the next login, and the name and profile picture for a new account. email gives the email address of the account. The site calls no other Meta API.

      Members can disconnect Facebook in their account settings at any time. A request to delete the data, made from Facebook, reaches the data deletion callback of the site, which removes the link to the Facebook account and answers with a confirmation code and a status page.

  2. Your privacy policy has to say what your site keeps of the people who log in with Facebook, what it does with it, and how they can ask for it to be deleted. The privacy policy page Poly Community drafts says this in its part about logging in with an account elsewhere, and names the providers that are on when it is drafted. Your page keeps the text it was made with. So when you turn Facebook on, press Open the policy guide in Poly Community → Settings → Privacy and copy that paragraph into your page again, now naming Facebook.

  3. Business verification: the app needs a business portfolio that Meta has verified, and App Review cannot be sent before. This holds even for logging in alone: under Use cases → Customize → Permissions and features, the Requirements of email and of public_profile both name Business Verification and Data handling questions, so leaving the email address out does not avoid it. Without it, Facebook shows its login dialog only to people with a role on the app. If you have none, press Start Verification on Publish and choose Create a new business portfolio: give it the public name of your community, with your name and email. Then start its verification in Meta Business Suite: the country, the legal name, address, phone, email and website, a way for Meta to confirm you are connected to it, and documents if Meta does not find it. Meta takes up to about two working days, and Review → Verification says In review until then. Have the documents and your website ready first: see What business verification asks.

  4. Review → App Review: the list of requests holds email and public_profile. Press Next. The form has five steps, and Submit for review turns on once all of them are done:

    • Verification: done once the portfolio is verified.
    • App settings: done once the basic settings above are complete.
    • Allowed usage: for each permission, tick that your site uses it as Meta allows (logging in with the email address of the Facebook account), and press Save.
    • Data handling: answer them yourself, or with whoever handles legal matters for your site. Meta asks:
      • whether other companies can reach the data from Facebook, and which: your host, for example, and any service your site sends names or email addresses to, such as payments,
      • who is responsible for the data, a person or an organization, named as in your business verification, and its country,
      • whether you gave personal data to public authorities for national security requests in the last 12 months,
      • which policies you have for requests from public authorities: a review of their legality, challenging unlawful ones, giving the least data needed, keeping a record of them, or none of these.
    • Reviewer instructions: the instructions of the Website platform. You may add files here, such as a screen recording of logging in with Facebook on your site, but they are not required.
    Submit for App Review: Verification with Go to verification, App settings, Allowed usage and Reviewer instructions done, Data handling still open
    Review → App Review → Next

    Meta reviews the whole app with it: the icon, the name, the privacy policy and the deletion callback. Its reviewers try the login on your site with test accounts of their own, and turn down an app they cannot reach, so turn Facebook on as you press Submit for review (step 8). Never give the password of your own Facebook account.

  5. Once Meta approves, open Publish and publish the app.

What business verification asks​

Meta checks three things, and turns the verification down when any of them does not match. Its message names which one, with Make updates to try again.

  • The legal name, entered exactly as it is written on your document, letter for letter. A sole trader or a self-employed person uses the name the business is registered under. Meta accepts a certificate of registration or articles of incorporation, a business licence or permit, a bank statement or a bank letter. A document of any other kind is turned down.
  • The address, on a document that shows the legal name and the address together: one of the documents above, or a water, gas, electricity or phone bill.
  • The website you enter, which has to show the legal name, spelled as on the document. Put it in the footer of your site or in your terms of service, for example "Run by Example Trading Ltd".

A bank statement or a bank letter for the account of the business often shows both its legal name and its address, so one document can cover the first two.

What Facebook gives your site​

The ID of the account for your app, the name, the email address and the profile picture. Poly Community asks for the picture at 640 pixels and leaves out the blank silhouette of an account without a photo.

Facebook does not say whether the email address is confirmed, and an account made with a phone number may have none. So:

  • Someone new confirms their address with a code on the sign-up form.
  • A member who already has an account with that address logs in to it once, and Facebook is connected from then on. See An account that already has the address.

Poly Community asks Facebook in the newest version of its Graph API, so a new app works. There is nothing to set for it.

When something goes wrong​

Facebook says the redirect URI is not allowed​

The Valid OAuth Redirect URI in the settings of the use case is not exactly the one in the dialog in WordPress, or it was pasted and not saved. Paste it again, press Enter so that it shows as an entry, and press Save changes. Check that nothing is added or left out: the same https, the same www or none, no slash at the end.

Facebook says the app is not available​

The app is not published yet, and the account is not one of its roles. Add the person as a tester under App roles → Roles, or publish the app (step 9).

Someone new has to type their email address​

Facebook gave no address: the email permission was not added to the use case (step 3), the person took it away under Edit access on the Facebook screen, or their Facebook account has no email address.

The login comes back with "Facebook could not be reached, or its answer could not be checked"​

The App Secret in WordPress is not the one of the app, for example after Reset beside it in the basic settings. Copy it again. Services → Single sign-on shows the failure with the words of Facebook.

Meta could not verify your business​

The message from Meta says what did not match: the legal name, the address or the website. Correct that one as What business verification asks describes, then press Make updates in the message and upload an accepted document. Until the business is verified, App Review cannot be sent, and only people with a role on the app can log in with Facebook. Turn the button off meanwhile (step 7), so that no one else meets the error from Facebook.

Anything else​

A Forbidden page from your host right after Facebook, a login that always says it took too long, or a button that does not show: these happen with every provider and are on Common problems.