Skip to content

Set up Facebook

Yanik Peiffer edited this page Apr 24, 2016 · 1 revision

Login via Facebook

Set up

  1. Install and activate this plugin
  2. Create a Facebook developer account
  3. Create a new Facebook app for websites. You will receive an app id that we will need later
  4. In your WordPress backend go to "Settings" -> "JWT" -> "Facebook"
  5. Activate the authentication method
  6. Enter you Facebook app id
  7. Enter you Facebook app secret
  8. In order to use Facebook as an authentication method for WordPress, you have to set the checkbox for creating new users if no matching account was found.

Authentication for Rest-API

After the setup facebook is ready to use for you WordPres Rest API. In order to receive a JSON Web Token that you will have to use to access endpoints you have to make the following HTTP request:

GET YOUR_URL/wp-json/wp-jwt/v1/login?method=facebook&code=FB_CODE

Parameters

Parameter Value Description
method (required) facebook auth method
code temporary facebook code the facebook code you receive from facebook after the user is logged in (required if token is not set)
token temporary access-token the facebook access-token you receive from facebook (required if code is not set)
set_wp_cookie true/false if true wp auth cookies are created and the user can access the backend
redirect_to URL Location the user gets redirected to on success

Response

On success you will receive a JSON Web Token. Whenever you make a request to secure endpoints you have to send this token via the authorization header.

POST /wp-json/endpoint HTTP/1.1
Host: YOUR_DOMAIN
Authorization: Bearer TOKEN_HERE

Show login buttons

Instead of using this plugin for the Rest API you can use Facebook as an alternative login/registration method for your wordpress site.

  1. In your backend go to "Settings" -> "JWT" -> "Facebook"
  2. Under "Facebook Login-Button" you can activate the "Login with Facebook" button
  3. Now you will see a new button on your login page /wp-login.php

Facebook

Clone this wiki locally