Reputation: 7761
I am adding Facebook login to my expo app and it says in the documentation to enter my expoClientId
somewhere.
The problem is I cant figure out where to put it. Do I put it in my app.json? Maybe my package.json? In the Facebook developer portal somewhere? Maybe I put it in my expo console somewhere?
Does anyone know where the expoClientId
should live? The documentation doesn't say where to put it.
Edit: It looks like I also need to place an iosClientId
and an androidClientId
as well.
Upvotes: 3
Views: 757
Reputation: 7761
Turns out you pass it in the request to authorize with facebook like this:
import * as React from 'react';
import * as WebBrowser from 'expo-web-browser';
import * as Facebook from 'expo-auth-session/providers/facebook';
import { ResponseType } from 'expo-auth-session';
import { initializeApp } from 'firebase/app';
import { getAuth, FacebookAuthProvider, signInWithCredential } from 'firebase/auth';
import { Button } from 'react-native';
// Initialize Firebase
initializeApp({
/* Config */
});
WebBrowser.maybeCompleteAuthSession();
export default function App() {
const [request, response, promptAsync] = Facebook.useAuthRequest({
responseType: ResponseType.Token,
clientId: <YOUR FBID>,
expoClientId: <YOUR FBID>, //this is where you add them
iosClientId: <YOUR FBID>,
androidClientId: <YOUR FBID>,
});
React.useEffect(() => {
if (response?.type === 'success') {
const { access_token } = response.params;
const auth = getAuth();
const credential = FacebookAuthProvider.credential(access_token);
// Sign in with the credential from the Facebook user.
signInWithCredential(auth, credential);
}
}, [response]);
return (
<Button
disabled={!request}
title="Login"
onPress={() => {
promptAsync();}}
/>
);
}
Upvotes: 2
Reputation: 385
It seems it's a part of the FacebookAuthRequestConfig interface which is used as useAuthRequest()
parameter (Expo src).
Upvotes: 3