0

Im having an Issue when i try to sign up with face book get the following in the log cat

  07-11 10:15:07.757: W/com.facebook.Session(8910): Should not pass a read permission (user_likes) to a request for publish or manage authorization
07-11 10:15:07.772: W/com.facebook.Session(8910): Should not pass a read permission (email) to a request for publish or manage authorization
07-11 10:15:07.777: W/com.facebook.Session(8910): Should not pass a read permission (user_birthday) to a request for publish or manage authorization
07-11 10:15:07.787: W/com.facebook.Session(8910): Should not pass a read permission (user_location) to a request for publish or manage authorization
07-11 10:15:08.797: V/log_tag(8910): Token=
07-11 10:15:08.797: V/log_tag(8910): Token=false

I followed the proper documentation of facebook even Used the code to generate the SHA key and placed it on console disable sand box enable face book login disable deep linking but still no luck Code that i used for face book is following

facebookBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            Session.openActiveSession(SignIn_Rewards.this, true, new Session.StatusCallback() {

                // callback when session changes state
                @Override
                public void call(Session session, SessionState state,
                        Exception exception) {

                    Log.v("log_tag", "Token=" + session.getAccessToken());
                    Log.v("log_tag", "Token=" + session.isOpened());

                    Session currentSession = Session.getActiveSession();

                    if (currentSession == null || currentSession.getState().isClosed()) 
                    {
                         session = new Session.Builder(SignIn_Rewards.this).build();
                        Session.setActiveSession(session);
                        currentSession = session;
                    }


                    else if(!currentSession.isOpened())
                    {
                        //Ask for username and password
                        OpenRequest op = new Session.OpenRequest(SignIn_Rewards.this);

                        op.setLoginBehavior(SessionLoginBehavior.SSO_WITH_FALLBACK);
                        op.setCallback(null);

                        List<String> permissions = new ArrayList<String>();
                        permissions.add("publish_stream");
                        permissions.add("user_likes");
                        permissions.add("email");
                        permissions.add("user_birthday");
                        permissions.add("user_location");
                        op.setPermissions(permissions);


                        session = new Session.Builder(SignIn_Rewards.this).build();
                        Session.setActiveSession(session);
                        session.openForPublish(op);
                    }
                    else if (session.isOpened()) {




                        // make request to the /me API
                        Request.executeMeRequestAsync(session,
                                new Request.GraphUserCallback() {

                                    // callback after Graph API response with user
                                    // object
                                    @Override
                                    public void onCompleted(GraphUser user,
                                            Response response) {
                                        if (user != null) {
                                           /* TextView welcome = (TextView) findViewById(R.id.welcome);
                                            welcome.setText("Hello "
                                                    + user.getName() + "!");*/
                                            finish();

                                            Log.d("User Name",""+user.getName()+"     "+user.getFirstName()+"    "+user.getLastName()+"    "+user.getProperty("email")+user.getBirthday()+user.getLocation().getProperty("name"));
                                        }
                                    }
                                });
                    }
                }
            });


        }
    }) ;

please correct me where I am wrong

Usman Kurd
  • 7,212
  • 7
  • 57
  • 86
  • Does this help : http://stackoverflow.com/questions/15357811/how-to-integrate-facebook-in-my-android-application or http://stackoverflow.com/questions/15153312/facebook-login-cannot-pass-a-publish-or-manage-permission-email-to-a-request-f – Vrashabh Irde Jul 11 '13 at 05:45
  • no having no luck with that – Usman Kurd Jul 11 '13 at 05:54
  • You didn't post full code, so I cannot be sure, but the most common cause of a Session.open not doing anything is because you're not overriding the onActivityResult method to pass through the result to the active session. – Ming Li Jul 12 '13 at 00:04

1 Answers1

0

I've generally seen this problem happen because of the wrong hash key generation. Rather than doing all the keytool stuff try pasting this code in one of your onCreate to generate the right key and paste that to your app section on Facebook.

PackageInfo info;
try {
    info = getPackageManager().getPackageInfo("com.you.name", PackageManager.GET_SIGNATURES);
    for (Signature signature : info.signatures) {
        MessageDigest md;
        md = MessageDigest.getInstance("SHA");
        md.update(signature.toByteArray());
        String something = new String(Base64.encode(md.digest(), 0));
        //String something = new String(Base64.encodeBytes(md.digest()));
        Log.e("hash key", something);
    }
} catch (NameNotFoundException e1) {
    Log.e("name not found", e1.toString());
} catch (NoSuchAlgorithmException e) {
    Log.e("no such an algorithm", e.toString());
} catch (Exception e) {
    Log.e("exception", e.toString());
}

This will generate the key in your logcat. Check this for more ways to generate the hash key correctly

Community
  • 1
  • 1
Vrashabh Irde
  • 14,129
  • 6
  • 51
  • 103