Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 303
Che Avatar asked Apr 09 '15 06:04

Che


People also ask

How can I get Facebook token in Android?

To get the Client Access Token for an app, do the following: Sign into your developer account. On the Apps page, select an app to open the dashboard for that app. On the Dashboard, navigate to Settings > Advanced > Security > Client token.

How do you update your dependencies on Facebook?

Login into Facebook and navigate to https://developers.facebook.com/apps/ Select the App you want to upgrade (you might have access to multiple apps) Click Settings > Advanced. Select the latest version under the Upgrade API Version section for both “Upgrade All Calls” and “Upgrade Calls for App Roles”

How did you integrate the Facebook SDK in Android app?

To use the Facebook SDK in an Android Studio project, add the SDK as a build dependency and import the SDK. Go to Android Studio | New Project | Minimum SDK. Select API 15: Android 4.0. 3 (IceCreamSandwich) or higher and create your new project.


3 Answers

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();

        }
like image 86
Reham Mokhtar Avatar answered Nov 07 '22 03:11

Reham Mokhtar


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

like image 45
Tiago Oliveira Avatar answered Nov 07 '22 05:11

Tiago Oliveira


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);
}
like image 32
Ming Li Avatar answered Nov 07 '22 03:11

Ming Li