1

Im integrated parse and facebook sdk to my project and its work and i get id and user name of facebook user my issue is i cannot get any thing else like email or gender or any other information even i add the permission for them.

this is permission :

private static final List<String> Permissions = Arrays.asList("public_profile","email","user_friends","user_birthday","user_location","user_relationships");

button click code :

Button mBtnFb=(Button)findViewById(R.id.mBtnFb);

    mBtnFb.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ParseFacebookUtils.logInWithReadPermissionsInBackground(MainActivity.this,Permissions , new LogInCallback() {
                @Override
                public void done(ParseUser user, ParseException err) {
                    if (user == null) {
                        Log.d("MyApp", "The user cancelled the Facebook login.");
                    } else if (user.isNew()) {
                        Log.d("MyApp", "User signed up and logged in through Facebook!");
                        getUserDetailsFromFB();
                    } else {
                        Log.d("MyApp", "User logged in through Facebook!");
                        getUserDetailsFromParse();
                    }
                }
            });
        }
    });

get user details from facebook:

public String name,email;
ParseUser parseUser=new ParseUser();

private void getUserDetailsFromFB() {
    GraphRequest request = GraphRequest.newMeRequest(
            AccessToken.getCurrentAccessToken(),
            new GraphRequest.GraphJSONObjectCallback() {
                @Override
                public void onCompleted(
                        JSONObject object,
                        GraphResponse response) {

                    try {
                        String id=object.getString("id");
                        String name=object.getString("name");
                        String email=object.getString("email");
                        String gender=object.getString("gender");
                        String birthday=object.getString("birthday");

                    } catch (JSONException e) {
                        e.printStackTrace(); 
                    }
                }
            });
    Bundle parameters = new Bundle();
    parameters.putString("fields", "id,name,link,email");
    request.setParameters(parameters);
    request.executeAsync();

}

I get id and name only and any other info give me exception any suggestion ?

FarOoOosa
  • 311
  • 1
  • 5
  • 16
  • visit this ink http://stackoverflow.com/a/29379794/5202007 or http://stackoverflow.com/a/13205830/5202007 – Mohammad Tauqir Aug 30 '15 at 20:25
  • in those 2 solution not using parse im using parse as they include in there documentation and also for FB so it should be not loginbutton and also not using session – FarOoOosa Aug 31 '15 at 18:08
  • I would try the same call with the same access token on the Graph API Explorer and see if you get the data back, if not then this is not an SDK issue but simply you don't have access to the data (email) – ifaour Sep 09 '15 at 13:04

1 Answers1

1

I had exactly the same issue, here's how I solved it:

  1. Go to https://developers.facebook.com/
  2. Click "Tools & Support" (at top menu)
  3. Click "Graph API Explorer" (at left side menu called "Tools")
  4. Where it says "Application: Graph API Explorer" (at the top right) change it to the application you are working with.
  5. Where it says "Get Token" click "Get User Access Token"
  6. Tick "user_about_me"
  7. Click on "Extended Permissions"
  8. Tick "email"
  9. Click "Get Access Token"
  10. Facebook may prompt you to confirm.

This should then give your application the permission to retrieve the email address of the facebook user.

Hope this helps.

Regards, Nathanial