Search code examples
androidfacebookfacebook-android-sdkfacebook-access-token

Check if app is de-authorized facebook android SDK 4.0


Trying to integrate Facebook Android SDK 4.0 via a sample app.

Questions:

  1. How can we check if the app has been de-authorized by the user in the app dashboard. Tried using the AccessTokenTracker in the new SDK documentation, but that doesn't seems to be getting called upon when i de-authorize the app.

The AccessTokenTracker is only called when i login or change the password on the account. Is there any other class for checking the de-authorization of an app?

The sample app: https://github.com/facebook/facebook-android-sdk/blob/b384c0655fe96db71229bfdcb981a522f3f1e675/samples/Scrumptious/src/com/facebook/scrumptious/MainActivity.java

  1. Where exactly is the AccessToken stored in our app?

The documentation on the developer.facebook is real poor as of now. I only want to use the SDK. I don't intend to use the Graph API along with that. Any ideas is appreciated.

Thanks!


Solution

  • 1) You won't get a call on the client when the user de-auths your app. What will happen is when you do a call, it will fail. The GraphResponse's getError will be not null. In this case, the FacebookRequestError's category is LOGIN_RECOVERABLE, as you need to take the user to the login flow again. You can call one of these methods to start that process with the response you received: https://github.com/facebook/facebook-android-sdk/blob/b384c0655fe96db71229bfdcb981a522f3f1e675/facebook/src/com/facebook/login/LoginManager.java#L96-L115

    2) The access token is stored in your application's shared preferences under the key com.facebook.AccessTokenManager.CachedAccessToken