React native facebook auth

Viacheslav Volkov
2 min readMay 15, 2021

If you want to use Facebook authorization in your react native application you have to configure your facebook application at https://developers.facebook.com . You should add Android sign in and 2 important parameters. First one — Google Play Package Name and second — Key Hashes. There are no any questions with first one. But how to find second one? Let me describe it.

First of all you should go to your Google play developer console and open Setup-App Integrity and copy SHA-1 certificate fingerprint for App signing key certificate and after that convert this hex value to base64. For example you can do it with this link. And that is it.

I prefer to use expo facebook library to simplify integration. For exaple this is my react hook.

const handleFacebookClick = useCallback(async () => {
setIsLoading(true);
try {
await Facebook.initializeAsync({
appId: FACEBOOK_APP_ID,
});
const result = await Facebook.logInWithReadPermissionsAsync({
permissions: ['public_profile'],
});
if (result.type === 'success') {
const authData: IAuthData = {
externalId: result.userId,
identityToken: result.token,
};
processJoin(EXTERNAL_TYPE.FACEBOOK, authData);
} else {
setIsLoading(false);
}
} catch ({ message }) {
setIsLoading(false);
}
}, [processJoin]);

--

--

Viacheslav Volkov

JS Developer from London, UK. Working with React, React Native and Typescript. https://github.com/VeXell