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.
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.
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”
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.
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();
}
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
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);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With