Login Error: There is an error in logging you into this application. Please try again later

AndroidFacebookFacebook Graph-ApiFacebook Login

Android Problem Overview


I am getting this error. When I try to sign in with facebook to my app. When I first time authentication it will correctly working. After I unistalled my application and now trying to sign in with Facebook on that I am getting this error.

Another Issue : After authenticate in device1 and try to login with facebook on device2 also same error is getting.

Solution I Found : when I remove App authentication from Facebook App Settings it is working in above scenario's but this is not an good solution how we can tell to users to do this action?

btnFbLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(accessToken != null) {
                    boolean expires = accessToken.isExpired();
                    if(!expires) {
                        performFbLoginOrSignUp(accessToken);
                    }
                } else {
                    LoginButton loginButton = (LoginButton) findViewById(R.id.login_button);
                    callbackManager = CallbackManager.Factory.create();

                    if (loginButton != null) {
                        loginButton.setReadPermissions("public_profile", "email", "user_friends");

                        if (CommonUtil.isConnectingToInternet(LoginActivity.this)) {
                            loginButton.performClick();

                            loginButton.setPressed(true);

                            loginButton.invalidate();

                            loginButton.registerCallback(callbackManager, mCallBack);

                            loginButton.setPressed(false);

                            loginButton.invalidate();
                        } 
                    }
                }
            }
        });

Error page

In Facebook example also having an issue : GitHub link of Facebook example

Steps to reproduce :

  1. Launch the app Login with Facebook Authenticate FB profile.

  2. Un_install the app and install again.

  3. Now try to Login with Facebook.

  4. The above error will occur. because we already authenticated so need to access fb profile. but here we facing the issue.

  5. Here already authenticated page is not showing.

  6. I am using Native FB app with the device Xiaomi Redmi Note 3

Android Solutions


Solution 1 - Android

The error occurs because of invalid hash key.

We can create Hash key using the below command and update the same here under Settings-> Basic -> Android HashKeys

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

You can find the Relase Key Alias of your keystore using the below command if needed:

keytool -list -keystore ADD_UR_KEYSTORE_PATH_HERE

I have also experience an issue like by using the above HashKey the login works fine if I install the release APK directly to the device, But when I upload the APK to Play Store and install app from store then it shows the same Login failed error. The fix for this is as follows:

  1. Go to Release Management here

  2. Select Release Management → App Signing

  3. You can see SHA1 key in hex format App signing certificate.

  4. Copy the SHA1 in hex format and convert it in to base64 format, you can use this link do that without the SHA1: part of the hex.

  5. Go to Facebook developer console and add the key (after convert to base 64) in the 

    settings → basic → key hashes

Solution 2 - Android

ANSWER

Just throwing this out there for people still experiencing this issue. The hash I created through the keytool was somehow incorrect. I fixed it by doing the following:

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):

  1. Login into the Google Play Console
  2. Click on the app you want the hash from
  3. Now, open the navigation on the left hand side
  4. Under Release click Setup > App integrity Navigation drawer in the Google Play Console
  5. Under App signing certificate copy the SHA-1 certificate fingerprint
  6. Go to http://tomeko.net/online_tools/hex_to_base64.php
  7. Paste the SHA-1 in the first field
  8. Copy the text in input field under Output (base64)
  9. Now open developer.facebook.com/apps
  10. Navigate to the dashboard of your app (My Apps > Your App Name)
  11. On the left side navigate to Settings > Basic
  12. Paste the Base64 text here under Key Hashes enter image description here

That should fix the issue.


UPDATE

The steps above should still fully work.

But if you do not want to paste your key on that website, here is an alternative to step 6,7,8 below:

> here's a oneliner Node.js command to do the same:

node -e 'console.log(Buffer.from(process.argv[1].split(":").map(hex => parseInt(hex, 16))).toString("base64"))' '5E:8F:16:06:2E:A3:CD:2C:4A:0D:54:78:76:BA:A6:F3:8C:AB:F6:25'

credits: mifi


Solution 3 - Android

I also Face this problem .Update your key hash on Facebook

Solution 4 - Android

enter image description here

enter image description hereFnnK.jpg

solutions are -------------- Set LoginBehavior if you have installed facebook app in your phone loginButton.setLoginBehavior(LoginBehavior.WEB_ONLY);

Solution 5 - Android

This is the issue from Facebook. Confirmed by Facebook Team.

enter image description here

We will Expected Resolution: within 3 days

Solution 6 - Android

  1. Generate .apk file

  2. open a terminal where .apk file exists

  3. to keep in your mind that you have to generate two separate SHA1 keys for release and debug. e-g just run following command with debug.apk and release.apk

  4. run keytool -list -printcert -jarfile yourapkname.apk

  5. you will get

> MD5: 00:00:A0:00:00:00:72:00:00:B9:00:00:00:3D:00:00 > > SHA1: 00:00:94:00:67:00:FA:00:4E:00:CE:80:00:1A:00:00:00:00:00:00 > > SHA256: 00:00:00:34:00:00:00:00:00:00:00:00:00:00:00:00:56:00:F5:00:00:49:00:4A:00:00:00:00:00:00:00:00

  1. copy SHA1 open http://tomeko.net/online_tools/hex_to_base64.php
  2. past in Hex string your Key Hash will be in Output (base64)
  3. copy your Key Hash and add in your App setting on developers.facebook.com

Solution 7 - Android

For me, this exact error was due to invalid permission strings. Happened on iOS and Android.

Solution 8 - Android

I faced the same problem.

It was a mistake on my side.

keytool -exportcert -alias <RELEASE_KEY_ALIAS> -keystore <RELEASE_KEY_PATH> | openssl sha1 -binary | openssl base64

When typed this command, it prompted Enter keystore password:. I was giving the keyPassword instead storePassword and it didn't gave any error message instead generated a different hash!

Solution 9 - Android

I resolved the same issue by replacing the key hash,

How to generate the key hash for release. Open Chrome browser console to convert a hex map key to base64

Copy SHA1 key from google play console.

> btoa('a1:43:d4:27:c8:04:rr:fr:2g:3b:tg:b5:et:c1:4a:1t:fr:f5:54:5f'.split(':').map(hc => String.fromCharCode(parseInt(hc, 16))).join(''))
< "g5fGIBgB6noFO9ur78BdEr73KG6="

Solution 10 - Android

  1. Remove app from user settings in Facebook (account).

  2. Uninstall the app.

  3. Get the new hash using the release or new debug keystore. Use this command:

     keytool -exportcert -alias <RELEASE_KEY_ALIAS> -keystore <RELEASE_KEY_PATH> | openssl sha1 -binary | openssl base64
    
  4. Add the new hash on Facebook dashboard.

Solution 11 - Android

This problem occurs because you've already authenticated the app via Facebook and your code may contain Authenticate every time Facebook (Find and Remove that).

Follow these steps:

  1. Go to Facebook settings.

  2. Remove your app.

  3. Make sure you've added Facebook Login in Facebook developer page and you've enabled Client OAuth Login.

  4. Go to your code and override the callback method:

     @Override
     public void onActivityResult(int requestCode, int resultCode, Intent data) {
     	super.onActivityResult(requestCode, resultCode, data);
     	mFacebookCallbackManager.onActivityResult(requestCode, resultCode, data);
     	if (resultCode == RESULT_OK) {
     		Intent secondActivityIntent = new Intent(this, RedirectActivity.class);
     		startActivity(secondActivityIntent);
     	}
     }
    
  5. In the Oncreate method, call the AccessToken:

     accessTokenTracker = new AccessTokenTracker() {
     	@Override
     	protected void onCurrentAccessTokenChanged(
     			AccessToken oldAccessToken,
     			AccessToken currentAccessToken) {
     		// Set the access token using
     		// currentAccessToken when it's loaded or set.
     	}
     };
    
     // If the access token is available already assign it.
     accessToken = AccessToken.getCurrentAccessToken();
    
     if (accessToken != null && !accessToken.isExpired())
     {
     	GraphRequest request = GraphRequest.newMeRequest(accessToken, new GraphRequest.GraphJSONObjectCallback() {
     		@Override
     		public void onCompleted(JSONObject object, GraphResponse response) {
     			if(null != object) {
     				try
     				{
     					Intent i = new Intent(MainActivity.this, Feedback.class);
     					startActivity(i);
     					String email = object.getString("email");
     					String birthday = object.getString("birthday");
     				  
     				}
     				catch (Exception ex)
     				{
     					Toast.makeText(MainActivity.this, ex.toString(), Toast.LENGTH_SHORT).show();
     				}
     			} else {
     				// call your authentication process
     			   
     			}
     		}
     	});
     	Bundle parameters = new Bundle();
     	parameters.putString("fields", "id,name,birthday,link");
     	request.setParameters(parameters);
     	request.executeAsync();
     }
    

Solution 12 - Android

I was facing the same issue. I had my keyhashes defined perfectly, was still facing the same issue. I was not able to login even for the first time.

Solution to my problem was:

  1. Go to your app's dashboard here
  1. On the left pane, under products tab, ensure that you have Facebook Login added. If not, add it there.

If all your other configurations are in place. It works perfect after that.

Solution 13 - Android

I refer this,

https://developers.facebook.com/docs/android/getting-started

or just add below code in onCreate() method, which will return key hash.

 // Add code to print out the key hash
try {
    PackageInfo info = getPackageManager().getPackageInfo(
            "com.facebook.samples.hellofacebook", 
            PackageManager.GET_SIGNATURES);
    for (Signature signature : info.signatures) {
        MessageDigest md = MessageDigest.getInstance("SHA");
        md.update(signature.toByteArray());
        Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
        }
} catch (NameNotFoundException e) {
    
} catch (NoSuchAlgorithmException e) {
    
}

Add above code to retrieve key,that key you can store

https://developers.facebook.com/docs/facebook-login/android

here. Now It will work.

It worked for me, hope will work for you too.

OR

This command may not give you latest keyhash.

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

To get latest or active keyhash from android studio search 'hash' in your android studio's Logcat or android monitor while app is running and throwing above error. You will get different keyhash which is active. After pasting this searched keyhash in your console setting you may log be able to your app.

Solution 14 - Android

I had the same problem on my Redmi Note 3. Tested on Samsung. No problems. Wonder if it is Redmi specific.

Solution 15 - Android

The problem for me is really with the hash key, It's not valid.

I had exactly the same problem and it was very hard to diagnose. The reason is that Facebook doesn't check the hash key at first login and it seems that the key is correct, but indeed it's not. Second, the error message is simply an idiocracy. Third is the resolution: try the following link, it helped me.

Better instructions to generate a valid hash key

Solution 16 - Android

I faced the same issue and I found that the hash key which I have generated to put in facebook developer console is not proper. I tried to generate hash key from different PC and it asked me to enter password for that particular keystore which was not the case in my PC. So make sure that you will asked to enter key store password while creating hash key then insert that hash key into facebook developer console.

Command to generate hash key:

keytool -exportcert -alias TYPE ALIAS HERE -keystore KEY_STORE_FILE_PATH_HERE | openssl sha1 -binary | openssl base64

Solution 17 - Android

I had the same problem today on my sites and then realised that I was using the old default_graph_version = v3.2. I've changed it to the latest:

> default_graph_version = v4.0

Now everything works again. Give it a try.

Solution 18 - Android

The issue for me (at the time of writing this) was when adding hash directly in Facebook Login -> Settings page. For some strange reason it does not save it correctly.

I fixed this with going to Quickstart and adding hashes in one of the steps and hitting Save. (fix will probably be obsolete when they fix their web page)

I did not have an issue with the tool, it generated correct hash. People with wrong Play store hashes probably have Play store signing enabled or entered wrong credentials.

Solution 19 - Android

if you setup the key hash correctly, it may be related to the facebook app. This is occurring only on Android if the facebook application is installed on device! (to make sure, just uninstall the fb app and try again.) one solution is to authenticating using web and ignore the native fb app.

Solution 20 - Android

In our case, we use expo app and it does not support redirection to the app after login success. We needed to setup the configuration to not open the facebook app but the embedded browser or the phone's browser by specifying the behavior.

Facebook.logInWithReadPermissionsAsync({
  permissions: [
    "public_profile",
    "email",
    "user_birthday",
    "user_hometown",
    "user_location",
  ],
  behavior: "web"
})

Hope it help someone, we've lost many time solving this :)

Solution 21 - Android

I was getting this error when signing in from a different account. when i signed in using developer account i recieved this error Facebook Login: "The application has disabled the Oauth client flow for Facebook integration" which was solved by enabling Client Oauth login from facebook developer account->myApp->products-> Facebook Login

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNaveen Kumar MView Question on Stackoverflow
Solution 1 - AndroidMouzmiSadiqView Answer on Stackoverflow
Solution 2 - AndroidTafelView Answer on Stackoverflow
Solution 3 - AndroidLokesh MehtaView Answer on Stackoverflow
Solution 4 - AndroidDeepak parmarView Answer on Stackoverflow
Solution 5 - AndroidNaveen Kumar MView Answer on Stackoverflow
Solution 6 - AndroidRasheed QureshiView Answer on Stackoverflow
Solution 7 - AndroidKyle JohnsonView Answer on Stackoverflow
Solution 8 - Androidtouhid udoyView Answer on Stackoverflow
Solution 9 - AndroidSujeet KumarView Answer on Stackoverflow
Solution 10 - Androidmohamed sakrView Answer on Stackoverflow
Solution 11 - AndroidParthiban KannanView Answer on Stackoverflow
Solution 12 - AndroidAndroid MasonView Answer on Stackoverflow
Solution 13 - AndroidGaurav PawarView Answer on Stackoverflow
Solution 14 - AndroidBen LooiView Answer on Stackoverflow
Solution 15 - Androiduser732456View Answer on Stackoverflow
Solution 16 - Androidapurv thakkarView Answer on Stackoverflow
Solution 17 - AndroidpdolinajView Answer on Stackoverflow
Solution 18 - AndroidDusan ZivkovicView Answer on Stackoverflow
Solution 19 - AndroidGhonche YqrView Answer on Stackoverflow
Solution 20 - AndroidDaniView Answer on Stackoverflow
Solution 21 - AndroidHaseeb Hassan AsifView Answer on Stackoverflow