Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Facebook Module - Invalid access token on Android 2.3.x

$
0
0

Hi guys, I did a simple integration of the Facebook Module but I got strange errors only on 2.3.x Android versions:

  • on Android 2.3.3 emulator when I click the FB login button the app crashes after a dozen of seconds with a generic error. I've read somewhere that it can be an emulator problem.

  • on a REAL Android 2.3.7 device (with FB app installed) I can login the first time to Facebook with SSO, then correctly logout. After that, I can't login no more. Debugging directly on the device I can see this error:

    [ERROR][FacebookModule(13209)] (main) [95,95] LoginDialogListener onFacebookError: Invalid access token.
    [ERROR][FacebookModule(13209)] com.facebook.android.FacebookError: Invalid access token.
    and the login event handler is not fired. The code I used:

//tiapp.xml
 <property name="ti.facebook.appid">my-app-id</property>
//alloy.js
Alloy.Globals.Facebook = require('facebook');
//index.xml
<Alloy>
    <Window class="container">
        <!-- Use the Alloy.Globals.Facebook namespace to create a Facebook module login button -->
        <LoginButton id="fbButton" ns="Alloy.Globals.Facebook"/>
    </Window>
</Alloy>
//index.js
var facebook = Alloy.Globals.Facebook;
facebook.appid = "my-app-id";
facebook.permissions = [];
facebook.forceDialogAuth = false;
$.fbButton.style = facebook.BUTTON_STYLE_WIDE;
facebook.addEventListener('login', function(e) {
    if (e.success) {
        facebook.requestWithGraphPath('me', {}, 'GET', function(e) {
            if (e.success) {
                var data = JSON.parse(e.result);
                Ti.API.info(data.id);
            } else if (e.error) {
                alert(e.error);
            } else {
                alert('Unknown response.');
              }
        });
    } else {
        if (e.error) {
            alert(e.error);
        } else {
            alert("Unkown error while trying to login to facebook.");
        }
    }
});
facebook.addEventListener('logout', function(e) {
    //tried this outside the logout handler, just to reset cache on app launch, but without success
    var url = 'https://login.facebook.com';
    var client = Titanium.Network.createHTTPClient();
    client.clearCookies(url);
});
Titanium SDK: 3.1.2.GA on MacOS X. Facebook app is well configured, the FB integration works well in iOS emulator and Android 4.x emulator. Any suggestions?

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>