Chella M
Chella M

Reputation: 392

Access token removed in Facebook Android SDK 4.0

I am using Facebook Android SDK 4.0 (newly updated version). I logged in to my app after the initial setup. Then I exited from my app. If again start my app, user is not in the logged in state. When I use debugger, it shows "ACCESS TOKEN REMOVED". What is the procedure to check whether the user is in logged in state using Access Token?

I have tried new log in method (according to newer version 4.0) in which they mentioned about log in process. I have done it. But whenever I open up Access Token state is "ACCESS TOKEN REMOVED". I checked App id, Package name, Activity name in dash board settings. All are correct. Help me to find solution for this problem.

Upvotes: 10

Views: 14512

Answers (4)

Tiago Oliveira
Tiago Oliveira

Reputation: 1602

You can get the token by using

 AccessToken.getCurrentAccessToken().getToken()

Using this you can get the token at any time, if you use the LoginResult, you get it only once at the time you log in, when you restart the app the onSuccess is not called.

If you need the profile after restarting, you use

Profile.getCurrentProfile();

If this returns null you are not loged in

Upvotes: 7

Reham Mokhtar
Reham Mokhtar

Reputation: 179

you can get access_token by using loginResult.getAccessToken().getToken(); as following code

 LoginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {

          String accessToken= loginResult.getAccessToken().getToken();

        }

Upvotes: 17

Chella M
Chella M

Reputation: 392

I got the solution. I've execute GraphRequest method inside the separate thread. It is wrong approach. All asynch taks shoud be run inside the main thread.

Upvotes: 0

Ming Li
Ming Li

Reputation: 15662

By default the SDK will not log access tokens to logcat (this is to avoid leaking user tokens via the log).

You can, however, enable in debug mode a logging behavior to log the access token. Just add this when you're calling FacebookSdk.sdkInitialize(), but make sure to only do it when you're in debug mode:

if (BuildConfig.DEBUG) {
    FacebookSdk.setIsDebugEnabled(true);
    FacebookSdk.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS);
}

Upvotes: 13

Related Questions