Facebook oAuth

Install Facebook Auth plugin

Example for React app

Please, install node dependency
1
npm install react-facebook-login --save
Copied!
1
import FacebookLogin from 'react-facebook-login';
2
​
3
<FacebookLogin
4
appId={you_app_id_in_fb}
5
autoLoad={true}
6
fields="name,email"
7
onClick={(d)=>{
8
/** **/
9
}}
10
callback={(d)=>{
11
let url = `http://api.directual.com/good/api/v4/auth/`
12
let body = { provider: "fb", token: d.accessToken, clientID: you_app_id_in_fb }
13
fetch(url, {
14
method: 'POST',
15
body: JSON.stringify(req.body),
16
headers: {
17
'Content-Type': 'application/json'
18
}
19
}).then(res2=>{
20
res2.json().then(result=>{
21
res.end(JSON.stringify(result))
22
}).catch((data)=>{
23
res.end('error')
24
})
25
26
})
27
}} />
Copied!
​