GRiMe2D / facebook-actionscript-api

Automatically exported from code.google.com/p/facebook-actionscript-api
0 stars 0 forks source link

FacebookMobile : init fails, login hangs #369

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Call FacebookMobile.init(appId, callback) after the user's previous session 
has timed out.
2. The callback to FacebookMobile.init() has success=null, fail = { error : { 
message : "Error validating access token: Session has expired at unix time 
131822000.  The current unix time is 1318541586.", type : "OAuthException" }} 
3. A subsequent attempt to call FacebookMobile.login(callback, stage, 
permissions) will hang and not call the callback.

What is the expected output? What do you see instead?
FacebookMobile.init does not fail to initialize on a bad cached access token, 
or FacebookMobile.login prompts the user for a login and calls its callback. At 
the very least, I would expect FacebookLogin to call its callback with a 
failure.

What version of the product are you using? On what operating system?
1.8 / OSX 10.6

Please provide any additional information below.
The short form of the code having problems is below. The LoginDialog comes up 
with the "Error validating access token" message. After pressing the "login" 
button on the dialog, FacebookMobile.login() is called. loginCallback is never 
called:

  InitializeApp();

  // This was an experiment that turned out to have no effect
  // FacebookMobile.manageSession = false;
  FacebookMobile.init(AppInfo.appId, initCallback);

  function initCallback(success:Object, fail:Object):void {
    if ( success == null ) {
      LoginRequest.show(fail['error']['message'], "Login Required", onLogin);
    } else {
      // continue with logged-in user
    }
  }
  function onLogin():void {
    FacebookMobile.login(loginCallback, FlexGlobals.topLevelApplication.stage, AppInfo.appPermissions);
  }
  function loginCallback(success:Object, fail:Object):void {
    trace("loginCallback");
    // etc...
  }

Original issue reported on code.google.com by jason.ma...@gmail.com on 13 Oct 2011 at 10:06

GoogleCodeExporter commented 9 years ago
Tracing into this, it appears that if you attempt to use the default 
StageWebView created by FacebookMobile.login when you don't provide your own 
StageWebView is the issue. FacebookMobile.createWebView never sets the 
viewPort. It should either default the viewport to the size of the stage, or 
the webView parameter to FacebookMobile.login should be required to be non-null.

Original comment by jason.ma...@gmail.com on 20 Oct 2011 at 9:13

GoogleCodeExporter commented 9 years ago
Thanks for the heads up, a fix will be included in the next update

Original comment by edwar...@gmail.com on 27 Oct 2011 at 7:33

GoogleCodeExporter commented 9 years ago
What is the status of this bug?

Original comment by rtret...@happytoad.com on 7 Nov 2011 at 4:01

GoogleCodeExporter commented 9 years ago
The issue is that the viewPort is not being defined. Adding this to the 
showWindow function within the MobileLoginWindow class will fix the issue:

webView.viewPort = new Rectangle(0,0,webView.stage.width,webView.stage.height); 

here is the full updated function:
protected function showWindow(req:URLRequest):void {
            webView.viewPort = new Rectangle(0,0,webView.stage.width,webView.stage.height); 
            webView.addEventListener(
                Event.COMPLETE,
                handleLocationChange,
                false, 0, true
            );
            webView.addEventListener(
                LocationChangeEvent.LOCATION_CHANGE,
                handleLocationChange,
                false, 0, true
            );
            webView.loadURL(req.url);
        }

Original comment by rtret...@happytoad.com on 7 Nov 2011 at 4:28