facebookarchive / react-native-fbsdk

A React Native wrapper around the Facebook SDKs for Android and iOS. Provides access to Facebook login, sharing, graph requests, app events etc.
https://developers.facebook.com/docs/react-native
Other
2.99k stars 907 forks source link

Login Error : there is an error in logging you into this application. please try again later. #633

Open thisisbalaG opened 5 years ago

thisisbalaG commented 5 years ago

Hi,

I have followed the instructions properly and i got this error while i signed in into the app and did the facebook login.

This issue am getting is in android.

Please help facebook login error

maslhiro commented 5 years ago

me too

jordangrant commented 5 years ago

Ran into this, I believe it occurred when the Facebook app was on the Android device and signed in.

abhi-nahi commented 5 years ago

Facing same issue right now. This is occurring only on Android if the facebook application is installed on device.

naimoon6450 commented 5 years ago

Not sure if this is the same issue as well, but been stuck on this screen (for android) after login and can't find a fix

image

React Native Environment Info: System: OS: Linux 4.4 Ubuntu 18.04.1 LTS (Bionic Beaver) CPU: (4) x64 Intel(R) Core(TM) i5-7300U CPU @ 2.60GHz Memory: 724.09 MB / 7.89 GB Shell: 4.4.19 - /bin/bash Binaries: Node: 10.15.3 - /usr/bin/node npm: 6.4.1 - /usr/bin/npm npmPackages: react: 16.8.3 => 16.8.3 react-native: ^0.59.9 => 0.59.9 npmGlobalPackages: react-native-cli: 2.0.1

jordangrant commented 5 years ago

Hey guys, haven’t tried this yet but since it seems the issue is the native Facebook app. You could try setting the Login mode to web only so that it ignores the native app, as a workaround.

abhi-nahi commented 5 years ago

Hey guys, haven’t tried this yet but since it seems the issue is the native Facebook app. You could try setting the Login mode to web only so that it ignores the native app, as a workaround.

I'm pretty sure that this approach should not be considered as proper solution of the problem but I would definitely like to try this. Let me know if you have any tutorial/guide reference for this approach.

jordangrant commented 5 years ago

@abhi-nahi Correct, not a proper solution and hopefully this issue get fixed. Here's some more info on setting LoginBehavior https://stackoverflow.com/questions/39835006/how-do-i-set-loginbehaviour-when-using-react-native-fbsdk-loginmanager/47267836

You can pass this as a prop to LoginButton also to see which login types are working

abhi-nahi commented 5 years ago

@jordangrant Thanks, This thing works but still the question remains same. Why would anyone enter their credentials again if they already have Facebook installed ??

yanguyt commented 5 years ago

I had the same problem and solved like this, setting loginBehavior only for web, like the code below:

if (Platform.OS === "android") {
            LoginManager.setLoginBehavior("web_only")
        }

await LoginManager.logInWithPermissions(["public_profile", "email"])

I dont know why, but when you have facebook app installed react-native-fbsdk try to login with then, and nothing happen.

jordangrant commented 5 years ago

@abhi-nahi They wouldn't. Hence the bug report. My current workaround defaults to Web and allows user to manually change to native. If I leave it as native some people can't access my app.

{Platform.OS === 'android' &&
 <Text onPress={() => this.toggleLoginMode()}>
      {(this.state.loginMode == 'web_only' ? 'Login via Web (Tap to change)' : 'Login Automatically (FB App)')}
</Text>}

<LoginButton
  loginBehaviorAndroid={this.state.loginMode}
...
yasir-netlinks commented 5 years ago

Hi guys, any solution yet, I am experiencing the same with 1.0.3 and 1.0.4

thisisbalaG commented 5 years ago

I found a solution for this guys. Use this stable version "react-native-fbsdk": "^1.0.2". and add correct Hash keys for both development and release mode. It will work. Hope this helps.

yasir-netlinks commented 5 years ago

@thisisbalaG that doesn't support IOS 13

thisisbalaG commented 5 years ago

@yasir-netlinks I have a temporary solution for this. Since you cannot use separate versions of this library for android and iOS, Inside your node modules inside ./ios folder replace the RCTFBSDK and RCTFBSDK.xcodeproj from a lower version file in the library version "react-native-fbsdk": "^0.10.1". This will work

ducpt2 commented 5 years ago

+1 i had the same problem :(

Saad-Bashar commented 5 years ago

same issue

MrLoh commented 5 years ago

@janicduplessis any chance this will get a fix soon. Makes this library pretty unusable on android.

DevAelius commented 5 years ago

In Build apk login with facebook worked but when I prepare release apk, in release apk login with facebook throw error as thisisbalaG said I also put build & release a hash key.

alexnaldo commented 5 years ago

I had the same problem and solved like this, setting loginBehavior only for web, like the code below:

if (Platform.OS === "android") {
            LoginManager.setLoginBehavior("web_only")
        }

await LoginManager.logInWithPermissions(["public_profile", "email"])

I dont know why, but when you have facebook app installed react-native-fbsdk try to login with then, and nothing happen.

Working in current version of RN and SDK

MrLoh commented 5 years ago

Yes but thats a current workaround but not a solution. People should be able to log in with the Facebook app without reentering their password.

ahmadsdk commented 5 years ago

I had the same problem and solved like this, setting loginBehavior only for web, like the code below:

if (Platform.OS === "android") {
            LoginManager.setLoginBehavior("web_only")
        }

await LoginManager.logInWithPermissions(["public_profile", "email"])

I dont know why, but when you have facebook app installed react-native-fbsdk try to login with then, and nothing happen.

This is a temporary workaround, I hope a solution will be found.

jessk77 commented 5 years ago

same issue, not cool that people reenter their password :/

csnindreamer commented 5 years ago

if (Platform.OS === "android") { LoginManager.setLoginBehavior("web_only") } Const result = Await LoginManager.logInWithReadPermissions(['public_profile', 'email']);

if (result.isCancelled) {

  ToastAndroid.show("User cancelled request ", ToastAndroid.SHORT)
  console.log('User cancelled request'); 

}

else{ Const data = Await AccessToken.getCurrentAccessToken();

if (!data) {

 console.log('Something went wrong obtaining the users access token');

}

//here logincredential code

}### Its working for me

MrLoh commented 5 years ago

The issue is not that it's not working when using web-only but that it doesn't work without it. And users should not be forced to enter a password again.

Saad-Bashar commented 5 years ago

even when set to web_only behavior, in safari it opens up the browser and there is an option to login from the app by facebook so when the user tries that I does not work again :/

ngtan commented 5 years ago

That error occurred because of using invalid hash key in Facebook Developer. You need to export hash key by using the below command, then update generated hash key (28 characters) into https://developers.facebook.com/ under Settings-> Basic -> Android HashKeys

keytool -exportcert -alias ADD_RELEASE_KEY_ALIASE_HERE -keystore ADD_UR_KEYSTORE_PATH_HERE | openssl sha1 -binary | openssl base64

Saad-Bashar commented 5 years ago

@ngtan , thanks man. So I need to create a new hash key with my release key store? What should I do with the old one that is already there in facebook developer?

I understand your command for generating key hash, can you give a full example. Just wanted to see how does it look after adding key alias and key store path. Thanks a lot.

ngtan commented 5 years ago

@Saad-Bashar it's mine from FB developer.

Screen Shot 2019-10-28 at 11 08 54 AM
Saad-Bashar commented 5 years ago

@ngtan , I meant the cli command

pacozaa commented 4 years ago

Any update on this?

suryaj92 commented 4 years ago

Any update on this??

nguyenphufps commented 4 years ago

ATEFDAF me tooo

1290846731 commented 4 years ago

Any update on this??

ngtan commented 4 years ago

Hello @Saad-Bashar, FYI, here are my commands for generating hash key keytool -exportcert -alias androiddebugkey -keystore YOUR_PROJECT/android/app/debug.keystone | openssl sha1 -binary | openssl base64

keytool -exportcert -alias androidreleasekey -keystore YOUR_PROJECT/android/app/YOUR_RELEASE_FILE.keystone | openssl sha1 -binary | openssl base64

After got hash key from cli, just put them in FB developer as the image below

Screen Shot 2019-11-09 at 3 24 38 PM

I put 2 hash keys for both debug and release in FB developer.

feliperugai commented 4 years ago

Hello @Saad-Bashar, FYI, here are my commands for generating hash key keytool -exportcert -alias androiddebugkey -keystore YOUR_PROJECT/android/app/debug.keystone | openssl sha1 -binary | openssl base64

keytool -exportcert -alias androidreleasekey -keystore YOUR_PROJECT/android/app/YOUR_RELEASE_FILE.keystone | openssl sha1 -binary | openssl base64

After got hash key from cli, just put them in FB developer as the image below

Screen Shot 2019-11-09 at 3 24 38 PM

I put 2 hash keys for both debug and release in FB developer.

Just did this with both of your commands and the error persists :(

MrLoh commented 4 years ago

Can’t you discuss these completely unrelated things in a different issue or on stack overflow. This is exactly the reason why library maintainers drown in issues that it’s impossible to u der Stand what they are about.

ngtan commented 4 years ago

Hello @Saad-Bashar, FYI, here are my commands for generating hash key keytool -exportcert -alias androiddebugkey -keystore YOUR_PROJECT/android/app/debug.keystone | openssl sha1 -binary | openssl base64 keytool -exportcert -alias androidreleasekey -keystore YOUR_PROJECT/android/app/YOUR_RELEASE_FILE.keystone | openssl sha1 -binary | openssl base64 After got hash key from cli, just put them in FB developer as the image below

Screen Shot 2019-11-09 at 3 24 38 PM

I put 2 hash keys for both debug and release in FB developer.

Just did this with both of your commands and the error persists :(

Note that, androiddebugkey and androidreleasekey are your key alias for both dev and prod environment.

feliperugai commented 4 years ago

Following theses steps solved my problem: https://github.com/facebook/react-native-fbsdk/issues/424#issuecomment-469047955

tafelnl commented 4 years ago

If you already uploaded your app to the playstore and enabled "app signing by Google Play" there is a solution (at least this worked for me):

That should fix the issue.

MrLoh commented 4 years ago

Great but all of this is completely unrelated to the topic of this issue.

tafelnl commented 4 years ago

@MrLoh

That is not true. It is related to the topic.

I got the exact same error message and this is what I did to fix it. How is that unrelated?

MrLoh commented 4 years ago

@tafelnl So you can now login without web_only login behavior on Android?

tafelnl commented 4 years ago

@MrLoh

Yes, when the Facebook app is installed, it will make use of it.

MrLoh commented 4 years ago

@tafelnl thank you for the clear answer that this actually is related to the original issue and not a separate one as the original comment by Saad-Bashar suggested:

even when set to web_only behavior, in safari it opens up the browser and there is an option to login from the app by facebook so when the user tries that I does not work again :/

The issue is indeed solved by updating the key hashes. This probably happened to a lot of people, since the latest react native version changed the setup of the debug keystore.

tafelnl commented 4 years ago

@MrLoh You're welcome. Happy coding :)

Saad-Bashar commented 4 years ago

Thanks guys for the response. @tafelnl I am having one issue. After converting the sha-1 from my play console the base64 output that I get is incorrect in facebook developer key hashes. Am I doing something wrong? When I convert I do not get the = sign at the end of the string.

Update: Now I did it correctly. But still getting the same error in debug build. Do I need to delete the previous one?

tafelnl commented 4 years ago

@Saad-Bashar for debug you also need a debug key and not a release key as far as I am aware. I don't think app signing by google play store supports this. So you have to fall back to the keytool way. Here is a good explanation even for rookies: https://stackoverflow.com/a/46241386/8634342

thedukeatreides commented 4 years ago

I don't know why, but for me, the hash that FBSDK got for the release build scheme app is not the same that you get with keytool/openssl. What helped me is looking at the "adb logcat" output (just after attempting to log in) where I found:

BlueServiceQueue: X.2NP: [code] 404 [message]: Key hash %YOUR KEY HASH HERE% does not match any stored key hashes. (404) [extra]: null

and i used that hash for the fb console

hbarylskyi commented 4 years ago

Solution provided by @tafelnl works, though I used simpler way to get the hashes:

keytool -exportcert -alias YOUR_RELEASE_KEY_ALIAS -keystore YOUR_RELEASE_KEY_PATH | openssl sha1 -binary | openssl base64

This code is provided by Facebook in their Quickstart guide. Just make sure you're using correct value for your keystore password! This code generates different hashes if you provide different passwords and does not fail if you provide incorrect password.

tafelnl commented 4 years ago

@urvashikharecha

You should not use that method, as it provides really bad User Experience and seems not to be needed anymore. Please refer to my solution (https://github.com/facebook/react-native-fbsdk/issues/633#issuecomment-554335094) or the one @hbarylskyi mentioned at https://github.com/facebook/react-native-fbsdk/issues/633#issuecomment-571956106