-
Notifications
You must be signed in to change notification settings - Fork 2
Set up Facebook
Yanik Peiffer edited this page Apr 24, 2016
·
1 revision
- Install and activate this plugin
- Create a Facebook developer account
- Create a new Facebook app for websites. You will receive an app id that we will need later
- In your WordPress backend go to "Settings" -> "JWT" -> "Facebook"
- Activate the authentication method
- Enter you Facebook app id
- Enter you Facebook app secret
- 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.
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
Parameter | Value | Description |
---|---|---|
method (required) | 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 |
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
Instead of using this plugin for the Rest API you can use Facebook as an alternative login/registration method for your wordpress site.
- In your backend go to "Settings" -> "JWT" -> "Facebook"
- Under "Facebook Login-Button" you can activate the "Login with Facebook" button
- Now you will see a new button on your login page
/wp-login.php