tag:blogger.com,1999:blog-865923359735383241.post5662211630149430226..comments2023-10-29T07:27:09.012-06:00Comments on Ccna final exam - java, php, javascript, ios, cshap all in one: How to avoid already-authorized in Android Facebook SDKUnknownnoreply@blogger.comBlogger3125tag:blogger.com,1999:blog-865923359735383241.post-77883237920022117632012-06-08T19:16:40.637-06:002012-06-08T19:16:40.637-06:00Bypass the SDK and use your own OAuth solution. Sa...Bypass the SDK and use your own OAuth solution. Save the Access Token once acquired. Try to use it directly without sending the user to the facebook permission page. Once the token expires, you will need them to grant permission again. With advanced features comes lower level responsibilities (and more work).Userhttps://www.blogger.com/profile/11557173689529910046noreply@blogger.comtag:blogger.com,1999:blog-865923359735383241.post-2395826698676620222012-06-08T19:16:37.250-06:002012-06-08T19:16:37.250-06:00using the suggestion here, this is the code that w...using the suggestion here, this is the code that worked for me, hope it helps someone<br /><br />before login do this <br /><br />SharedPreferences prefs= PreferenceManager.getDefaultSharedPreferences(FacebookLogin.this); <br /> String access_token = prefs.getString("access_token", null); <br /> Long expires = prefs.getLong("access_expires", -1);<br /><br /><br /> if (access_token != null && expires != -1)<br /> {<br /> facebook.setAccessToken(access_token);<br /> facebook.setAccessExpires(expires);<br /> }<br /><br /><br /> if (!facebook.isSessionValid())<br /> {<br /> facebook.authorize(FacebookLogin.this, new DialogListener() {<br />...<br /><br /><br />after you successfully logged in do this<br /><br />String token = facebook.getAccessToken();<br />long token_expires = facebook.getAccessExpires();<br /><br />SharedPreferences prefs= PreferenceManager.getDefaultSharedPreferences(FacebookLogin.this);<br /><br />prefs.edit().putLong("access_expires", token_expires).commit();<br /><br />prefs.edit().putString("access_token", token).commit();Userhttps://www.blogger.com/profile/11557173689529910046noreply@blogger.comtag:blogger.com,1999:blog-865923359735383241.post-86212608809599678532012-06-08T19:16:34.507-06:002012-06-08T19:16:34.507-06:00The way I did it (without additional OAuth solutio...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.<br /><br />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).<br /><br />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.Userhttps://www.blogger.com/profile/11557173689529910046noreply@blogger.com