48

I am using the Facebook SDK but I want to create the photo album but I am getting ACCESS_TOKEN_REMOVED in the session.

Getting this in session

{Session state:OPENED, token:{AccessToken token:ACCESS_TOKEN_REMOVED permissions:[read_stream, manage_friendlists, read_mailbox, status_update, photo_upload, video_upload, sms, create_event, rsvp_event, email, xmpp_login, create_note, share_item, publish_stream, ads_management, read_insights, read_requests, manage_notifications, read_friendlists, manage_pages, publish_actions, user_birthday, user_religion_politics, user_relationships, user_relationship_details, user_hometown, user_location, user_likes, user_activities, user_interests, user_education_history, user_work_history, user_online_presence, user_website, user_groups, user_events, user_photos, user_videos, user_photo_video_tags, user_notes, user_checkins, user_about_me, user_status, basic_info]}, appId:458921577539675}

Code.

/**
 * Connect to facebook using Facebook SDK.
 */
public void connectToFacebook() {
    Session session = Session.getActiveSession();
    if(session == null || session.isClosed()) {
        Session.openActiveSession((Activity)context, true, new StatusCallback() {
            @Override
            public void call(Session session, SessionState state, Exception exception) {
                if(session.isOpened() && state == SessionState.CREATED_TOKEN_LOADED) {
                    Log.v(GlobalVars.TAG, "Token::" + session.getAccessToken());
                    Request.executeMeRequestAsync(session, new GraphUserCallback() {
                        @Override
                        public void onCompleted(GraphUser user, Response response) {
                            if(response != null) {
                                Log.v(GlobalVars.TAG, "Response::" + response);
                                Log.v(GlobalVars.TAG, "Response::" + user.getFirstName() + ":::" + user.getLastName());
                            }
                        }
                    });
                }
            }
        });
    }
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
}
user2695306
  • 589
  • 2
  • 7
  • 9
  • The SDK won't directly log your access token, which is why you're seeing ACCESS_TOKEN_REMOVED. Are you seeing an error with your request? – Ming Li Aug 19 '13 at 18:06
  • @MingLi I am seeing this error when `call` method is executed. Please help me why its so? – user2695306 Aug 20 '13 at 21:19
  • 9
    You don't need to check for "state == SessionState.CREATED_TOKEN_LOADED", in fact, that's the wrong check. Just session.isOpened() is enough. My previous comment refers to that the SDK will NOT log your access token in logcat for security purposes, which is why you're seeing ACCESS_TOKEN_REMOVED (rather than the real access token). – Ming Li Aug 20 '13 at 21:25
  • but how would the implementation know that the user is trying to forward the output to Logcat ?There is no point in the above assertion. – Ankur Gautam Jan 25 '14 at 18:56
  • 1
    session.getAccessToken() – Shereef Marzouk May 15 '14 at 07:37

5 Answers5

60

If you are just seeing ACCESS_TOKEN_REMOVED in your log, make sure you are printing session.getAccessToken().getToken(). In the example above, replace

Log.v(GlobalVars.TAG, "Token::" + session.getAccessToken());

with

Log.v(GlobalVars.TAG, "Token::" + session.getAccessToken().getToken());
emidander
  • 2,383
  • 22
  • 29
  • 3
    This should be marked as the correct answer. Facebook doesn't allow devs to Log "session.getAccessToken" directly, because it may cause leaks. Whoever faces the same issue, should also check this for more information: [http://stackoverflow.com/a/29544390/2754871](http://stackoverflow.com/a/29544390/2754871) – Gökhan Mete ERTÜRK Oct 28 '15 at 18:18
58

Same problem that i was facing from last 2 days and finally i get to know this. Facebook SDK will not log access tokens to logcat (to avoid leaking user tokens via the log as said in decsription).

Just add these lines after FacebookSdk.sdkInitialize(), i would recomend you do this only in debug mode:

if (BuildConfig.DEBUG) {
    FacebookSdk.setIsDebugEnabled(true);
    FacebookSdk.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS);
}
Ravinder Bhandari
  • 2,546
  • 21
  • 25
1

You have to enable facebook sign in on Firebase Console and add the facebook app id and app secret key and it should work fine

Nivil Boban
  • 286
  • 1
  • 13
0

I took the same problem :/

You can check:

  1. Is appId correct?
  2. Was keyhash registered in facebook app center?
  3. Does app namespace / package name match with your manifest file? ( on facebook app center )
  4. Is application live?

If everything is right I really don't know how to help you...

Fernando Martínez
  • 1,057
  • 10
  • 13
-3

I checked all items that Fernando said and add it

Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);

I don't know if this last line was what solved the problem or if it's something random.

I'm using Facebook Android SDK 3.17 for Xamarin

Greetings from Argentina Hernan www.hernanzaldivar.com

tomrozb
  • 25,773
  • 31
  • 101
  • 122
Vackup
  • 652
  • 4
  • 11