expo: Expo-Facebook login won't redirect back to Expo Client app when using login with Facebook app
đ Bug Report
Environment
Expo CLI 3.9.0 environment info: System: OS: macOS 10.14.5 Shell: 3.2.57 - /bin/bash Binaries: Node: 12.13.1 - ~/.nvm/versions/node/v12.13.1/bin/node Yarn: 1.19.2 - ~/.yarn/bin/yarn npm: 6.12.1 - ~/.nvm/versions/node/v12.13.1/bin/npm IDEs: Xcode: 11.0/11M337n - /usr/bin/xcodebuild npmPackages: expo: ^35.0.0 => 35.0.1 react: 16.8.3 => 16.8.3 react-native: https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz => 0.59.8 react-navigation: ^4.0.10 => 4.0.10 npmGlobalPackages: expo-cli: 3.9.0
Expo Client on iOS device
Steps to Reproduce
I recently tried to add login with Facebook to my application. I just copied the logIn function from here
https://docs.expo.io/versions/v35.0.0/sdk/facebook/
When I run my app via Expo Client, and execute the logIn function it
- Redirects me to a page asking if I want to use the Facebook app for login or use phone or email
- If I use phone or email login works perfectly fine
- If I select
Use Facebook Appit takes me to the Facebook app, it saysYou have previously logged into [MY_APP] and then I pressContinuea white screen shows up with theCancelbutton on the top left. It never goes back to my app and never resolves this functionlogInWithReadPermissionsAsync`.
Expected Behavior
It should have gone back to the Expo Client app where my app was running and it should have resolved the promise and returned (type === 'success') { so I could use the token and called GraphQL Apis
Actual Behavior
A white screen shows up with the Cancel button on the top left. It never goes back to my app and never resolves this function logInWithReadPermissionsAsync.
Reproducible Demo
async logIn() {
try {
const {
type,
token,
} = await Facebook.logInWithReadPermissionsAsync(`MY_APP_ID`, {
permissions: ['public_profile', 'email'],
});
if (type === 'success') {
// Get the user's name using Facebook's Graph API
const response = await fetch(`https://graph.facebook.com/me?access_token=${token}`);
Alert.alert('Logged in!', `Hi ${(await response.json()).name}!`);
} else {
// type === 'cancel'
alert(`Facebook Login Cancel`);
}
} catch ({ message }) {
alert(`Facebook Login Error: ${message}`);
}
}
render() {
return (
<Button onPress={this.logIn}><Text>Login</Text></Button>
)
}```
<!--
Please share a project that reproduces the issue.
There are two ways to do it:
* Create a new app using https://snack.expo.io/ and try to reproduce the issue in it.
This is useful if you roughly know where the problem is, or canât share the real code.
* Or, copy your app and remove things until youâre left with the minimal reproducible demo.
This is useful for finding the root cause. You may then optionally create a Snack.
This is a good guide to creating bug demos: https://stackoverflow.com/help/mcve
Once youâre done, copy and paste the link to the Snack or a public GitHub repository below.
(Even if your issue can only be reproduced in a standalone app, please include a Snack
or GitHub repo we can use to build a standalone app!)
-->
<!--
What happens if you skip this step?
Someone will read your bug report, and maybe will be able to help you,
but itâs unlikely that it will get much attention from the team. Eventually,
the issue will likely get closed in favor of issues that have reproducible demos.
Please remember that:
* Issues without reproducible demos have a very low priority.
* The person fixing the bug would have to do that anyway. Please be respectful of their time.
* You might figure out the issues yourself as you work on extracting it.
Thanks for helping us help you!
-->
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 123 (17 by maintainers)
This solution is only for you as a developer, but we cannot publish our apps like this. I had to remove the Facebook login from my app when i publish it as it will be very inconvenient for the user.
I Can confirm every non working examples.
Working example: While logged in to Facebook via Safari Browser, initiate FB Login from expo client App. The login process will happen in the browser and redirect back to expo client app.
For me the redirection does not happen when Login happens in the Facebook app and not in the browser.
Expo SDK 36.0.0 expo-facebook 8.0.0
@CaioMars I went back to expo build instead of eas build for the time being. There is probably a bug with the eas build at that time of building.
Hi everyone, has there been any progress on this issue? Iâm hitting this on a brand new empty Expo Client app on SDK 37.
Hahaha! Yeah, i did, I meant @Muhammad-Saleet⌠Thanks!
@CaioMars
Iâve solved this problem by using expo-facebook instead of expo-auth-session.
The code ended up looking something like this:
Weâll be releasing an update to the App Store Expo Client with this fix included soon, most likely next week
Same here. I created brand new Expo 36 app with facebook integration and its not working. Once redirect to facebook login, it provides option to login with Facebook app but when I chose facebook app then nothing happens.
Iâm using Bare workflow too. It sounds like itâs a configuration problem to me, your code looks good. There are a lot of little steps to configure it properly. Did you follow the instructions in Expo Facebook Auth Documentation?
Full disclosure, I am no expert on third-party authentication. Itâs one of those things I rarely do and by the time I have to do it again I already forgot how to. But here are few things to check:
Facebook Dev console (App > Settings > Basic):
For iOS:
For Android:
To see your key hashes run in the root of your project:
app.json
Make sure you have added these values to your
app.jsonfile. Note that one hasfbpreceeding your app ID and the other doesnât.Android Manifest
Add to your manifest:
I hope this helps.
haha, I think you mentioned the wrong person @CaioMars
This issue is for the App Store Expo Client app, not standalone or bare apps. If youâre seeing this issue in a bare app please create a new issue with a reproducible demo included.
Most likely you have not included the relevant facebookScheme and facebookAppId in info.plist if youâre seeing this in the bare workflow
incorrect. we still face this from time to time without any logic
Hi guys, I confirm that the problem only appears when the application is run on the device via the expo client. Today I did a test by doing a build and sending it with TestFlight. The login works !
@asabadyr could you share the code with us?
@YahiaBadr please read my and other comments more carefully. As I already mentioned, cruzach has reproduced the bug in Expo client https://github.com/expo/expo/issues/6459#issuecomment-608441099 and is likely working on a fix.
@vandervillain following your exact steps worked for me in the expo Client. After installing the Facebook app, did you log in to the app? (i did not)
Sorry everyone, itâs obvious that there is some issue here but without a reliable way to reproduce it itâs very hard to debug on our end đ If you want to investigate in your own further, I think the best next step is to take a look at the device logs and see if thereâs anything interesting there, and then Iâd also recommend testing
expo-facebookin a bare workflow projectI can make it happen 100% of the time on my iPhone 6S. replication steps:
youâll end up on an empty white screen with âcancelâ button in top left. If you feel like it, open safari, facebook.com, login, and then try again. Youâll be able to get into your app just fine. Obviously wonât be sufficient for an actual production application.
To fix this issue you just have to modify the bundle ID with the real one in the facebook developers page: Instead of host.exp.Exponent you put your com.yourapp and it should work.
This issue still happens to me. I get the white screen mentioned above: initializeAsync -> logInWithReadPermissionsAsync -> facebook app -> continue (allow access) -> white screen (within facebook app) with Cancel top left. Doesnt redirect back to the app. Switching back to Expo Client have to click Cancel again - only then logInWithReadPermissionsAsync resolved with cancel type.
Even with production mode = true same issue.
expo 36 and expo-facebook v8
I have the same issue, running on my Expo app using iPhone 8 Plus. Hope this will get fixed soon.
âexpoâ: â~36.0.0â âexpo-facebookâ: â^8.0.0â
Same issue with my Expo app on prod iOS. The Facebook app doesnât return to the Expo app after authorization. âhost.exp.Exponentâ is the bundle ID on my appâs Facebook settings.
âexpoâ: â^36.0.0â âexpo-facebookâ: â~8.0.0â
Iâve had trouble redirecting back to my app when the bundle ID of my app at https://developers.facebook.com/ was set to my own bundle ID, rather than the Expo Client bundle id -
host.exp.Exponent. Please make sure you are following the docs. If itâs not redirecting back to your app, itâs probably trying to find the app associated with the bundle ID youâve put in that field. You can confirm this by installing the standalone app via testflight, and then it will probably redirect to that appHere are my steps:
I added the following fields to my app.json facebookScheme facebookAppId facebookDisplayName
You can check the expo-facebook page on where to get them from
I also followed the steps to release an app to Testflight and ensured that my bundleId matches what apple has
When I did not have the app on Testflight installed on my phone it did not redirect back
When I downloaded my app from Test Flight and tried the FB login from there (Not the expo client) it worked fine.
I created a brand new app, it is still the same. After upgrading to v36
actually itâs been fixed đ
make sure to clear npm cache / expo cache and package-lock.json
@cruzach I tried now with the updated version 3.6 and unfortunately the same behavior @nnasiruddin explained in the description of the bug, it is still reproducible on my side. The Facebook login does never returns the logInWithReadPermissionsAsync method (after initializeAsync is done). We remain with the white screen shows up with theCancelbutton on the top left. It never goes back to my app and never resolves this.
Is there some redirects needed to be included in the app.json file which maybe we are missing? Or other important setups?