I'm getting a completely useless page when I use the Single Sign on for Facebook's Android SDK.
"You have already authorized happyapp. Press "Okay" to continue.
This page would destroy user experience. How the heck do I get rid of it. Lots of people have been seeing this, but no solution is posted.
Even Facebook admits this is a problem, see: http://forum.developers.facebook.net/viewtopic.php?id=84548
Does anyone know any work-around?
So far, to log out Facebook programmatically, I used : Session session = Session. getActiveSession(); session. closeAndClearTokenInformation();
To learn more about using Facebook development tools, see App Development. The current version of the Facebook SDK for Android is version 14.1. 1 and requires the Android API 15.
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”
The way I did it (without additional OAuth solution) was to store off the access token in preferences as Kieveli suggested. When the main activity starts, look up the token from preferences, if it's not there initiate the authorization process and store the resulting token in preferences.
The harder part is to handle token expiration or de-authorization of your app (ie. the token is in preferences, but is no longer valid).
For that case, with every FB API/graph invocation, check for an exception indicating authentication failed. If it fails, initiate the authorization/token storing procedure again.
using the suggestion here, this is the code that worked for me, hope it helps someone
before login do this
SharedPreferences prefs= PreferenceManager.getDefaultSharedPreferences(FacebookLogin.this); String access_token = prefs.getString("access_token", null); Long expires = prefs.getLong("access_expires", -1); if (access_token != null && expires != -1) { facebook.setAccessToken(access_token); facebook.setAccessExpires(expires); } if (!facebook.isSessionValid()) { facebook.authorize(FacebookLogin.this, new DialogListener() { ...
after you successfully logged in do this
String token = facebook.getAccessToken(); long token_expires = facebook.getAccessExpires(); SharedPreferences prefs= PreferenceManager.getDefaultSharedPreferences(FacebookLogin.this); prefs.edit().putLong("access_expires", token_expires).commit(); prefs.edit().putString("access_token", token).commit();
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