Expo Facebook: Error 'Given URL is not allowed by the Application Configuration.'

Hello, I’m trying to get Facebook Login working using the expo-facebook package.

I created my application in the Facebook Developer Console and copied the “App ID”.

This is the code im using inside my React Native Expo app:

async facebookLogin() { 
    await Facebook.initializeAsync('26327628297297')
    const response = await Facebook.logInWithReadPermissionsAsync({ permissions: ['public_profile']})

My understanding is that while using the Expo Client App there is no need to do any extra configuration because it will be using Expo’s Facebook App ID for all API calls.

I also tried added “facebookScheme” to my app.json but that didnt seem to help:
"facebookScheme": "fb26327628297297",

The problem is that after logging in I get this error message:
Given URL is not allowed by the Application configuration: One or more of the given URLs is not allowed by the App’s settings. To use this URL you must add a valid native platform in your App’s settings.

Thanks for your time.

I have a wild guess)
I think that you are using custom expo client (this is the client that starting on IOS simulator for example).
If this is the case try adding platform in facebook developer and fill bundle ID that i think provided by cli.
Here is the section in Docs: https://docs.expo.io/versions/latest/sdk/facebook/#ios-custom-expo-client

Hello, thanks for your reply. I dont have a custom expo client. Im using the regular client inside of an android emulator.

Ok, I think the problem can be in using with explicit appID. It is overriding default Expo Client appID and trying to use yours. Try calling initializeAsync like this:

async facebookLogin() { 
    await Facebook.initializeAsync()
    const response = await Facebook.logInWithReadPermissionsAsync({ permissions: ['public_profile']})

For release app be sure to include facebookAppId and facebookDisplayName in app.json and add your ID back in init.

I tried with Facebook.initializeAsync() and I get the error “Facebook Login Error: A valid Facebook app id must be set…”

Sorry pal, I don’t know what to do next.
My theory is that you need to add facebookID in app.json and try with ID passed to Facebook.initializeAsync() again. If app using yours facebookID then you need to configure it in facebook developer console like it is said in facebook docs. Try adding this bundle ID for android platform in facebook docs host.exp.exponent, maybe something will change.

I think it is kinda impossible that your app inside Expo Client trying to use your Facebook ID because it is required to pass Facebook ID to native android project to work properly. it is Expo Client installed on simulator or yours standalone app in dev mode?

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.