78

I am using Facebook login in android.
Code:

callbackManager = CallbackManager.Factory.create();
    LoginButton loginButton = (LoginButton) this.findViewById(R.id.login_button);
    loginButton.setReadPermissions("email", "public_profile");
    loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            // App code
            Log.println(Log.ASSERT, "FB", "inicio session ");
        }

        @Override
        public void onCancel() {
            Log.println(Log.ASSERT, "FB", "OP NO completada");
            // App code
        }

        @Override
        public void onError(FacebookException exception) {
            Log.println(Log.ASSERT, "FB", " Errro de sesion ");
            exception.printStackTrace();
            // App code
        }
    });

but always getting the following error:

SERVER_ERROR: [code] 1675030 [message]: Error performing query. [extra]: Errors while executing operation "ProxyAuthAppLoginQuery": At Query.proxy_auth_app_login: Failed to resolve field. W/System.err:
at com.facebook.login.LoginManager.onActivityResult(LoginManager.java:190) W/System.err: at com.facebook.login.LoginManager$1.onActivityResult(LoginManager.java:159) W/System.err: at com.facebook.internal.CallbackManagerImpl.onActivityResult(CallbackManagerImpl.java:82) W/System.err: at com.procibernetica.moca.MainActivity.onActivityResult(MainActivity.java:130) W/System.err: at android.app.Activity.dispatchActivityResult(Activity.java:5423) W/System.err: at android.app.ActivityThread.deliverResults(ActivityThread.java:3401) W/System.err: at android.app.ActivityThread.handleSendResult(ActivityThread.java:3448) W/System.err: at android.app.ActivityThread.access$1300(ActivityThread.java:138) W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1284) W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102) W/System.err:
at android.os.Looper.loop(Looper.java:149) W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5061) W/System.err: at java.lang.reflect.Method.invokeNative(Native Method) W/System.err: at java.lang.reflect.Method.invoke(Method.java:515) W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787) W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:603) W/System.err: at dalvik.system.NativeStart.main(Native Method)

I've added the folowing permissions.

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Neeraj Sewani
  • 3,952
  • 6
  • 38
  • 55
Daniel ORTIZ
  • 2,488
  • 3
  • 21
  • 41

18 Answers18

82

I find the solution, this happends when you don't have evaluate users in your app .

Enter in your panel App Select Rol

enter image description here

And add test users , when your try to login with test users , the application executes without fails

enter image description here

Ahmed Ashour
  • 5,179
  • 10
  • 35
  • 56
Daniel ORTIZ
  • 2,488
  • 3
  • 21
  • 41
  • 12
    It's worth noting that the reason for needing to do this is because your app is in "development mode" (see the setting for this located on the "App Review" panel). Development mode apps are considered private and can only be used by specifically-authorized users. Making the app public removes this restriction, so is an alternative to listing the users you want to have access. – Jules Feb 11 '17 at 01:17
  • This is not working in my case , but getting same exception. can u help? I've added tester now login with tester account. still same exception – Mohsin Feb 17 '17 at 05:16
  • 2
    Another solution is set app as public , follow the response of @AMAN SINGH , and refresh tokens – Daniel ORTIZ Feb 17 '17 at 13:17
  • I have my app published, yet i'm seeing the same error. Also I double checked to make sure my App ID is correct – Gabriel Apr 13 '17 at 21:26
  • I feel like this error is happening for me because I owe Facebook money from previous advertisements. – grantespo Apr 18 '17 at 07:07
  • 1
    @Gabriel did you manage to solve the issue? I'm presenting the same problem. I have our app published and yet this still happens. – fillipvt Oct 19 '17 at 23:00
  • did anyone get the solution to issue – Faisal Naseer Oct 24 '18 at 04:41
  • For me the `LoginManager.getInstance().loginBehavior` was default to `NATIVE_WITH_FALLBACK` changing to `WEB_VIEW_ONLY` Fixed it – Tristan Richard Aug 09 '19 at 09:38
  • Yes, this step is important especially if you are in development mode. – Guster Jan 03 '20 at 07:58
63

Documentation on facebook is not correct. I had to add all 3 default permissions to make it work.

loginButton.setReadPermissions("email", "public_profile", "user_friends");
aloha
  • 709
  • 5
  • 9
  • 1
    Thanks man, this solution works for me the solution marked as correct above does not work. I do not if this is related with use a custom login, facebook, meaning in my app I changed the fbk login button for an android button. nevermind it works – Oscar Gallon May 15 '17 at 15:46
  • 1
    Works for me too but makes me wonder if all three read permissions are needed, why does the Facebook official documentation only mention "email" permission ? – zulkarnain shah Jan 27 '18 at 14:57
  • Thanks it worked for me after I omitted the `user_friends` – liorko Sep 25 '18 at 07:29
  • @liorko your comment is contradictory, you are thanking and saying that you omitted user_friends, please clarify – Akshay Vijay Jain Oct 14 '18 at 09:53
  • 1
    @AkshayVijayJain it's worked for me with this line:`loginButton.setReadPermissions("email", "public_profile")` – liorko Oct 14 '18 at 20:29
  • As of 2018 anyway, the FB app has email and public_profile read permissions set by default, so no need to set them again. – FractalBob Nov 19 '19 at 08:21
  • I had "email" and "public_profile" set as permissions and it worked on the emulators. To make it work on my real device, I needed to add also "user_friends". – stefita Feb 02 '21 at 12:58
  • @stefita I have set user_friends in code and I don't need that permission. So If I add the permission and not enabled the user_friends make any issues while going to app review My app's login loaded with two permissions, after adding the above three permissions it worked – sejn Nov 19 '21 at 05:29
23

@Danial answer correct, But I want to add some more in that. This types of error comes only when app your in under development. Follow this link and select your App. Then you can do two things here. From Roles tab you can allow login to your friends only or else select the App Review and make your app public then any one can able to logged in.

AMAN SINGH
  • 3,491
  • 6
  • 28
  • 44
16

I was getting a similar issue because Firebase UI was specifying the android:value. This is how I solved it:

    <application
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme.Base">

    <meta-data
        android:name="com.facebook.sdk.ApplicationId"
        tools:replace="android:value"
        android:value="@string/facebook_app_id" />
<acitivity
...
</activity>
...
CacheMeOutside
  • 699
  • 7
  • 24
14

Issue Log: SERVER_ERROR: [code] 1675030 [message]: Error performing query

And Accurate Solution for this Specific issue (Error performing query)
is answered by @aloha is by updating the query for access.
loginButton.setReadPermissions("email", "public_profile", "user_friends");

  1. Find where you facebook login button was called.
  2. Then set the ReadPermission for the button as "email", "public_profile", "user_friends"

image Reference

enter image description here

Issue Log: App Not Setup. This app is still in development mode. and you dont have access to it. register test user or ask an app admin for permission

  1. The app are not in Live Mode
  2. You are not listed as admin or a tester in
    https://developers.facebook.com/app/yourapp
  3. Your App Hashkey are not set. if Facebook app cant be on Live Mode you need a hashkey to test it. because the app are not yet Live. Facebook wont allow an access.

HOW TO CHANGE TO LIVE MODE
1. go to : https://developers.facebook.com
2. select your app on "My Apps" List
3. toggle the switch from OFF to ON

enter image description hereenter image description here

HOW TO ADD AS TEST OR ADMIN
1. go to : https://developers.facebook.com
2. select your app on "My Apps" List
3. go to : Roles > Roles > Press Add for example administratorenter image description here 4. Search your new admin/tester Facebook account.
enter image description here 5. admin must enter facebook password to confirm.then submit enter image description here
the new admin must go to developer.facebook page and accept the request
6. go to : https://developers.facebook.com

7. Profile > Requests > Confirm
enter image description here List item 8. Congratulation you have been assign as new Admin

HOW TO GET AND SET HASHKEY FOR DEVELOPMENT
as Refer to Facebook Login Documentation
https://developers.facebook.com/docs/android/getting-started/#create_hash
The most preferable solution by me is by code ( Troubleshooting Sample Apps )
it will print out the hash key. you can update it on
https://developers.facebook.com/apps/yourFacebookappID/settings/basic/
on Android > Key Hashes section

a step by step process on how to get the hashKey.

  1. Firstly Add the code to any oncreate method

    enter image description here

  2. Run The app and Search the KeyHash at Logcat

    enter image description here

step by step process on how Update on Facebook Developer.

  1. Open Facebook Developer Page. You need access as to update the Facebook Developer page: https://developers.facebook.com

  2. Follow the step as follow.

    enter image description here

halfer
  • 19,824
  • 17
  • 99
  • 186
Muhammad Asyraf
  • 1,748
  • 15
  • 20
  • So all three permissions need to be enabled in the app review of the Facebook developer account as well? Am I correct? 1. My app loading and shows the error performing query. After adding the email and user_friends, public_profile it shows the app not setup error in the UI. Does this will be fixed after reappealing the app? – sejn Nov 15 '21 at 16:21
12

All of the above answers didn't help me, what did was when you use this command

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64

to get the Key Hashes you put in facebook configurations.

it will ask you for a password, at first I didn't set any, so the issue happened, when I entered android as the password. it worked !

Ahmad Melegy
  • 1,530
  • 1
  • 16
  • 18
  • 1
    This solved it for me ! I had already changed the app id from strings.xml, and did many other suggested answers. Thanks a lot. – hilnius Sep 06 '18 at 21:02
7

Live developer mode Please check status of Developer mode. It must be "Live". Firstly, you need add privacy url for own facebook project which you want to test facebook login or sth .... Then enable developer mode (Turn on)

Thanh vũ
  • 169
  • 3
  • 1
5

I just fixed it by going to https://developers.facebook.com/apps/ and select my app then

switch to live mode

"from top left beside app ID"

Momen Zaqout
  • 1,508
  • 1
  • 16
  • 17
  • My app not able to switch, it shows the message as "You may not make your app available to all users" – sejn Nov 18 '21 at 17:03
4

In my case the generated hash key was wrong because i was using wrong OpenSSL. I was using openssl-0.9.8k_X64.zip instead of openssl-0.9.8e_X64.zip and this generated me a wrong hash key which caused this problem hope it helps some one i lost like 8 hours trying to figure this out.

Ivan
  • 557
  • 1
  • 3
  • 14
3

In my case problem was wrong generated Key Hash which need to submit on facebook app page Solution found on this article https://developers.facebook.com/docs/facebook-login/android/advanced

Manually Check Key Hash - You can print out the key hash sent to Facebook and use that value in App Dashboard. Make this change to onCreate() in your main activity:

try 
{
    PackageInfo info = getPackageManager().getPackageInfo(
                        "com.facebook.samples.loginhowto",
                        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) {  

}
kj007
  • 6,073
  • 4
  • 29
  • 47
user954174
  • 39
  • 3
3

for Flutter this was the fix

final LoginResult result = await FacebookAuth.instance.login(
      permissions: [
        'public_profile',
        'email',
        'pages_show_list',
        'pages_messaging',
        'pages_manage_metadata'
      ],
    );
Deepak Yadav
  • 227
  • 3
  • 4
  • Thank you sir, it's sad that flutter_facebook_auth[https://pub.dev/packages/flutter_facebook_auth] plugin does NOT state that in the docs! – Panagiss Apr 14 '22 at 17:54
2

This error is returned in other situations too - even when your app is public or you're listed as a tester.

Double check that your

<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>

is resolving to a correct Facebook App ID, especially if you dynamically specify it using gradle build, rather than hard coding it in strings.xml.

Voy
  • 5,286
  • 1
  • 49
  • 59
2

I addition to the other answers please also check that the email of the account being used to log in is verified.

Muddassir Ahmed
  • 518
  • 4
  • 19
2

you need to see if the user that connect in the phone facebook app is a user that have test or developer permissions in the facebook developers on the app page.

Or Azoulay
  • 179
  • 2
1

Add a string resource "facebook_application_id" in your strings.xml

replace APP_ID with your facebook app id

<string name="facebook_application_id" translatable="false">APP_ID</string>
S.D
  • 85
  • 8
1

I just added this line and it worked for me.

facebookLogin.setReadPermissions("email", "public_profile", "user_friends");
Abdul Basit Rishi
  • 2,268
  • 24
  • 30
  • Shall I need to enable all the above permissons facebook developer account? Or does it enable automatically? – sejn Nov 15 '21 at 16:42
  • In my account, it only have the public_profile and email as its permission. But if i use this it shows unspported request. Are you sure, shall I need to enable all the above three permissions for sure? – sejn Nov 16 '21 at 08:49
  • You can try to enable all the above permissions on developer account may be work for you. – Abdul Basit Rishi Nov 16 '21 at 08:52
  • If I not enable the above three and add only two permissions does it work? – sejn Nov 16 '21 at 09:31
  • I am getting Something went wrong error UI – sejn Nov 16 '21 at 09:31
  • post full error. – Abdul Basit Rishi Nov 16 '21 at 09:34
  • its same as unsupported request error – sejn Nov 16 '21 at 10:59
  • I have a clarification, If I add the above three permissions in the code and not enabled the user_friends option in the developer account, my app not get loading. Does this make any issue while going to the app review – sejn Nov 19 '21 at 04:34
1

try this, locate your app-debug.apk in android build folder

keytool -printcert -jarfile app-debug.apk | openssl sha1 -binary | openssl base64

paste it in facebook key hashes.

tofi lagman
  • 101
  • 1
  • 2
0

I dont know if this will help but from personal experience when you generate the development key you will need to type a password which is "android" and make sure you add the = after the code when you are adding it in the field on developers facebook domain

hyperscience
  • 113
  • 7