facebook login issue in my android application

276 Views Asked by At

I am using facebook login in my android app and it was working fine before. from around last one month login is not working. I heard that facebook has changed some features while loging-in like, now the users can give access to only specific information like email adress, birthdate etc. as again to one access called Basic information which was there before. this might be one of the reason why i am not able to logging in to FB. I compared my app with other app in app settings for facebook account. PFA the difference b/t the two apps

This shows My app permissions. This shows other example app permissions

anybody know how to change the permissions to individual ones like email address,birthday etc ??

1

There are 1 best solutions below

2
On
try this
    private void performFacebookLogin()
    {
        Log.d("FACEBOOK", "performFacebookLogin");
        final Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(this, Arrays.asList("email"));
        Session openActiveSession = Session.openActiveSession(this, true, new Session.StatusCallback()
        {
            @Override
            public void call(Session session, SessionState state, Exception exception)
            {
                Log.d("FACEBOOK", "call");
                if (session.isOpened() && !isFetching)
                {
                    Log.d("FACEBOOK", "if (session.isOpened() && !isFetching)");
                    isFetching = true;
                    session.requestNewReadPermissions(newPermissionsRequest);
                    Request getMe = Request.newMeRequest(session, new GraphUserCallback()
                    {
                        @Override
                        public void onCompleted(GraphUser user, Response response)
                        {
                            Log.d("FACEBOOK", "onCompleted");
                            if (user != null)
                            {
                                Log.d("FACEBOOK", "user != null");
                                org.json.JSONObject graphResponse = response.getGraphObject().getInnerJSONObject();
                                String email = graphResponse.optString("email");
                                String id = graphResponse.optString("id");
                                //String facebookName = user.getUsername();
                                System.out.println("Birthday--------------"+user.getBirthday());
                                System.out.println("User ID----------------"+user.getId());
                                System.out.println("LINK---------------------"+user.getLink());
                                System.out.println("username---------------"+user.getUsername());
                                System.out.println("Hashcode----------------"+user.hashCode());
                                System.out.println("Inner JSON--------------"+user.getInnerJSONObject());
                                System.out.println("Location-------------------"+user.getLocation());
                                System.out.println("class------------------------"+user.getClass());
                                System.out.println(user.getProperty("email"));


                                if (email == null || email.length() < 0)
                                {
                                    System.out.println(
                                            "Facebook Login"+
                                                    "An email address is required for your account, we could" +
                                            " not find an email associated with this Facebook account. Please associate a email with this account or login the oldskool way.");

                                    return;
                                }
                            }
                        }
                    });
                    getMe.executeAsync();
                }
                else
                {
                    if (!session.isOpened())
                        Log.d("FACEBOOK", "!session.isOpened()");
                    else
                        Log.d("FACEBOOK", "isFetching");
                }
            }
        });
    }