Hi! I need to access Facebook.handleAuthFromAccessToken from facebook-oauth package.
I need it in another file in my project. Is that possible? maybe like an import…
Thanks!
Hi! I need to access Facebook.handleAuthFromAccessToken from facebook-oauth package.
I need it in another file in my project. Is that possible? maybe like an import…
Thanks!
Hi! I finally realized that facebook-oauth is a meteor package (dumb me) and if you whish to use facebook login in meteor, that package is a dependency so it’s installed anyway (dumb me again). With that in mind, I don’t need to copy/paste code from that package anymore! This is the resulting code for the Meteor login handler:
import { Accounts } from 'meteor/accounts-base';
import { Facebook } from 'meteor/facebook-oauth';
const registerFacebookMobileLoginHandler = () => {
Accounts.registerLoginHandler('facebookMobileLogin', params => {
const data = params.facebookMobileLogin;
if (!data) {
return undefined;
}
const identity = Facebook.handleAuthFromAccessToken(
data.accessToken,
(+new Date()) + (1000 * data.expirationTime),
);
return Accounts.updateOrCreateUserFromExternalService(
'facebook',
{
...identity.serviceData,
},
identity.options,
);
});
};
export default registerFacebookMobileLoginHandler;
This is useful if you whish to do facebook auth from a mobile app using React Native as shown here https://medium.com/differential/react-native-meteor-oauth-with-facebook-3d1346d7cdb7
In that article you should replace the login handler code with the one here.