What are you trying to do here? Custom login?
If so, this is how I get the data from facebook. A button will redirect the user to fb to login and provide access via the **getLink** function. Fb will send the user back to the redirect page along with a code parameter in the URL. Use that code in the **processCode** function to exchange it in return for user data like first name, last name, email and account id
import * as queryString from 'query-string';
import { fetch } from 'wix-fetch';
const stringifiedParams = queryString.stringify({
client_id: 'XXXXXXXXX',
redirect_uri: 'https://www.domain.com/redirect-page',
scope: ['email'].join(','),
response_type: 'code',
auth_type: 'rerequest'
});
export function getLink() {
const facebookLoginUrl = `https://www.facebook.com/v10.0/dialog/oauth?${stringifiedParams}`;
return facebookLoginUrl;
}
export async function processCode(code) {
const response = await fetch(`https://graph.facebook.com/v10.0/oauth/access_token?client_id=${CLIENT_ID}&client_secret=${CLIENT_SECRET}&redirect_uri=https://www.domain.com/redirect-page&code=` + code, {
method: "get"
});
let result = await response.json();
return getBasicDetails(result);
}
async function getBasicDetails(result) {
const response = await fetch("https://graph.facebook.com/me?fields=id,email,first_name,last_name&access_token=" + result.access_token, {
method: "get"
});
let data = await response.json();
return data; // Over here we receive the email, first name, last name and account id from facebook, now how you use that is up to you
}