lmitchsmith / facebook-actionscript-api

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

When logging in a second time, doesn't prompt for username/password #297

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.Login.
2.Log out.
3.Login.

What is the expected output? What do you see instead?

Expecting to be prompted to username again, but instead it just uses the 
previous username/password I supplied.

What version of the product are you using? On what operating system?

Version 1.6 of API on PlayBook

Original issue reported on code.google.com by daniel.b...@gmail.com on 4 May 2011 at 2:05

GoogleCodeExporter commented 8 years ago
Can you provide some source code please?

Original comment by rovertn...@gmail.com on 10 May 2011 at 10:52

GoogleCodeExporter commented 8 years ago
I'm having the same exact issue on Android.

I noticed if i go into the application settings and clear all data, then it 
will prompt me for a username and pass when I go to login again. But for 
obvious reasons this isn't ideal. 

When I call logout using the web api then call login for the second time, it 
still always prompts for username and pass.

So that's why it's expected behavior for the mobile api as well. Does anyone 
have any ideas how when calling logout or maybe a function we should be using 
after the logout method to clear out any previous data so it will always ask 
for a username/pass?

Original comment by Bry...@gmail.com on 11 May 2011 at 4:51

GoogleCodeExporter commented 8 years ago
daniel.b..., are you using the FacebookDesktop API? If so make sure on logout 
you pass in your app-origin url. Also make sure FacebookDesktop.manageSession = 
false;

Original comment by rovertn...@gmail.com on 11 May 2011 at 3:49

GoogleCodeExporter commented 8 years ago
I'm using the mobile API on the BlackBerry PlayBook. I'll try the suggested 
things tonight.

Original comment by daniel.b...@gmail.com on 11 May 2011 at 3:54

GoogleCodeExporter commented 8 years ago
On Android, using the Mobile 1.6.1 Facebook api, I tried passing in 
FacebookMobile.manageSession=false; on my logout handler but when i go to log 
back in it still doesn't prompt me for a username and pass, just keeps using 
the old one.

I'm sort of confused by "appOrigin"

It says:
appOrigin:String (default = null) — (Optional) The site url specified for 
your app. Required for clearing html window cookie.

But there is no url, this is a native flex mobile project it's not inside a web 
page like a flash web app.

So all I had was just FacebookMobile.logout(logoutHandler);

Original comment by Bry...@gmail.com on 12 May 2011 at 12:48

GoogleCodeExporter commented 8 years ago
Bry..., the app origin is the "Site URL" specified in your app settings on 
Facebook (http://www.facebook.com/developers/apps.php). I would try setting 
that, then clearing your cache and all (so you know you're testing from a fresh 
start), and see if you can log out properly.

Original comment by rovertn...@gmail.com on 12 May 2011 at 3:10

GoogleCodeExporter commented 8 years ago
I see, well, in my case I actually had a site URL to put in there since I have 
a web version of my application so I went ahead and tried 
FacebookMobile.logout(logoutHandler,"http://mywebsite.com/"); cleared all 
application data then reinstalled, also I had 
FacebookMobile.manageSession=false; in the logout handler but...still when I 
logout, then log back in it just uses the old name and auto logs in. The only 
time it ever asks for the credentials again is if i clear the app data. 

On the web version I never passed a url in with the logout handler and it still 
asks for a username and pass every time. 

There seems to be several problems with the apu using the stage web view, For 
example on my xoom it gets stuck on a white webpage with success in the corner 
and never closes...but ill open up another issue for that to keep things 
organized here.

Thanks for trying to help, hope this bug gets fixed soon. Also, if it helps i'm 
using a nexus one.

Original comment by Bry...@gmail.com on 13 May 2011 at 7:27

GoogleCodeExporter commented 8 years ago
So daniel did you ever get this to work? Is anyone else having this issue? I 
did exactly what you recommended on my Nexus on and the bug persists. So if 
it's happening on my nexus, it's probably happening for anyone else using the 
sdk.

Original comment by Bry...@gmail.com on 16 May 2011 at 4:24

GoogleCodeExporter commented 8 years ago
Bry, I haven't tried it yet. Sorry about that, I'll try and get to it soon.

Original comment by daniel.b...@gmail.com on 16 May 2011 at 1:10

GoogleCodeExporter commented 8 years ago
Any update on this? I understand how to use the SDK, and have tested multiple 
times, reset data, cleared cache, uninstallled and reinstalled, and every time 
this issue persists.

Original comment by Bry...@gmail.com on 26 May 2011 at 1:29

GoogleCodeExporter commented 8 years ago
These two links shed some light on the issue. 

http://forum.developers.facebook.net/viewtopic.php?pid=347350

http://bugs.developers.facebook.net/show_bug.cgi?id=17217

The mobile sdk also relies on this solution to logout, so it is affected by 
this change. There seems to be a workaround posted in the comments of the 
second link, and this will be included in the next update if this bug goes 
unresolved. In the meanwhile, the workaround can be applied to the 
FacebookMobile.as logout() method. 

Original comment by edwar...@gmail.com on 30 May 2011 at 5:24

GoogleCodeExporter commented 8 years ago
Use below code for desktop or mobile logout. The "/" at the and of the uri 
variable is very important. 

public function logout(handler:Function = null):void {
  var uri:String = "http://apps.facebook.com/appname/";
  var params:URLVariables = new URLVariables();
  params.next = uri;
  params.access_token = FacebookDesktop.getSession().accessToken;

  var req:URLRequest = new URLRequest("https://www.facebook.com/logout.php");
  req.method = URLRequestMethod.GET;
  req.data = params;

  var netLoader:NetLoader = new NetLoader();
  netLoader.load(req);

  FacebookDesktop.logout(handler, uri);
}

Original comment by toprakk...@gmail.com on 9 Jul 2011 at 1:24

Attachments:

GoogleCodeExporter commented 8 years ago
Yes, escalate and land in next update please. Why hasn't the SDK been updated 
since April? 

Original comment by Kevin.Su...@gmail.com on 11 Jul 2011 at 7:21

GoogleCodeExporter commented 8 years ago
I've done everything suggested here and cannot get the user to log out - has 
anyone successfully fixed this?

Original comment by rymoor...@gmail.com on 23 Aug 2011 at 11:28

GoogleCodeExporter commented 8 years ago
I am using the AS3 - Facebook Mobile API in an Adobe AIR application for 
Playbook which allows users to Login to the app via Facebook (in place of a 
registration).

The problem arises when user logs out from the app and wants to register using 
an alternate facebook id.

In the app we are calling the FacebookMobile.logout() function when user logs 
out and this works fine when testing on desktop. When user tries to connect 
through facebook again, the facebook login screen comes up and he's able to 
provide alternate account details to login.

However on the playbook the screen is shown only for the first time. Subsequent 
attempts to connect using facebook displays the webview but even before the 
page loads the user is  automatically authorized and the application uses his 
credentials to log him in. Basically he is locked into using the same account 
every time with no possible way for him to use another facebook account!

Please note that a similar behavior was happening in the app even during 
desktop testing prior to appending the "access_token" param to the logout call. 
However after adding this, the issue is resolved on the desktop but not on the 
Playbook device.

Have tried all of the above suggestions with the following results:

1. passing the access_token along with the logout call in FacebookMobile.as
 - Fixed the problem when testing on desktop
 - Problem persists on the Playbook Device.

2. Tried passing "http://apps.facebook.com/<<appname>>/" instead of the 
redirect_url.
 - Continues to work fine when testing on desktop.
 - Problem persists on the Playbook Device.

Basically - unable to logout user on Playbook!

Please note that FacebookMobile.manageSession has been set to false. So the 
failure must be happening due to cookie stored in the browser cache. Also even 
clearing the cache and cookies from the playbook's default browser doesn't 
clear the session either (Although this was resolving the issue on desktop even 
when logout was unsuccessful earlier on).

Wonder if this is an issue with the way AIR behaves on Playbook device itself 
or with facebook API or with the AS3 library?

Any help in this regard would be highly appreciated.

Original comment by chetan.m...@gmail.com on 25 Aug 2011 at 10:51

GoogleCodeExporter commented 8 years ago
Is this still an issue with the latest api?

Original comment by edwar...@gmail.com on 26 Oct 2011 at 8:07

GoogleCodeExporter commented 8 years ago
This issue is fixed. When you use the logout method you should pass the 
optioinal parameter which is the app's site url. This can be set from here 
(https://developers.facebook.com/apps) Look at the attached image.

Original comment by heit...@gmail.com on 27 Oct 2011 at 12:22

Attachments:

GoogleCodeExporter commented 8 years ago
I thought I would share my experiences regarding this issue as I have spent 
quite some time getting it to work.

When testing locally on my machine just passing the app origin in the logout 
function is enough to log the user out, however this alone doesn't seem to work 
when the app is being run on my Galaxy S2.

To fix this I create a new stageWebView and call the Facebook logout page 
manually along with the next and session parameters as well as calling the 
FacebookMobile logout function. I found that as long as the stage assigned to 
the stage web view was the same as the one used for the login window it always 
logged the user out as well as allowing the FacebookSession to stay managed 
which is exactly what I wanted for my app.
I disposed the stage web view on a complete event and made the viewport width 
and height of 0 therefor the user doesn't even realise this is being done.

It will be interesting to see if other people find themselves with a similar 
scenario as described and hopefully this has been helpful for them.

Original comment by matt@rancon.co.uk on 29 Oct 2011 at 5:55

GoogleCodeExporter commented 8 years ago
if you could post or email details of your workaround that would be fantastic, 
because according to facebook mobile below you can't logout from facebook using 
mobile logout....

/**
         * Clears a user's local session.
         * This method is synchronous, since
         * its method does not log the user out of Facebook,
         * only the current application.
         * 

Original comment by d.impos...@gmail.com on 30 Oct 2011 at 11:32

GoogleCodeExporter commented 8 years ago
#18 is right, this issue is fixed on the desktop but NOT for mobile. I will try 
your solution tomorrow and will report my findings – I have to find a 
solution for this very soon for my project.

Original comment by marc.wei...@googlemail.com on 5 Nov 2011 at 12:26

GoogleCodeExporter commented 8 years ago
#18,

could you please give us a code example? 
I'm struggling with this as well, and can confirm that it works on desktop but 
not in mobile (android) app.

thanks!

Original comment by str...@gmail.com on 8 Nov 2011 at 6:36

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Additional finding:

http://kb2.adobe.com/cps/895/cpsid_89526.html#main_Cookies_are_handled_different
ly_across_mobile_and_desktop_platforms

(see the very bottom table)-

It turns out that on Android, stagewebview doesn't share its cookies. 
This explains why the logout feature works fine on a desktop AIR app, but 
doesn't work on an actual android device.  
(this proves #18 above correct)

now I just gotta figure out how to clear cookies in stagewebview :)

Original comment by str...@gmail.com on 8 Nov 2011 at 5:09

GoogleCodeExporter commented 8 years ago
alright,

cannibalizing some code, and tweaking it a bit, here's how I got it working on 
my android tablet:
(my "next" url = http://m.facebook.com/  -- you could use something else)

Notes:  
1-you can NOT urlencode the parameters. if you do, it won't work.  I listed 
them out literally, but you could also do string replacements.
2- I also exposed the Access token in facebookMobile.as like so (yes, it's a 
hack):

public static function get accKey():String
        {
            return getInstance().accessToken;
        }

3- the handler is used, so that when the redirect happens, I can killl the 
stagewebview.

protected function reallyLogout():void
            {
                logoutWebView = new StageWebView();
                logoutWebView.viewPort = new Rectangle(0,50,0, 0);
                logoutWebView.stage = this.stage;

                var loginRequest:URLRequest = new URLRequest();
                loginRequest.method = URLRequestMethod.GET;
                loginRequest.url = "https://m.facebook.com/logout.php?next=http://m.facebook.com&access_token="+FacebookMobile.accKey+"&confirm=1";

                logoutWebView.addEventListener(
                    Event.COMPLETE,
                    handleLocationChange,
                    false, 0, true
                );

                logoutWebView.addEventListener(
                    LocationChangeEvent.LOCATION_CHANGE,
                    handleLocationChange,
                    false, 0, true
                );

                logoutWebView.loadURL(loginRequest.url);

            }

protected function handleLocationChange(event:Event):void
            {
                if (logoutWebView && event.target.location=="http://m.facebook.com/")
                {
                    logoutWebView.removeEventListener(Event.COMPLETE,handleLocationChange);
                    logoutWebView.removeEventListener(Event.LOCATION_CHANGE,handleLocationChange);
                    logoutWebView.dispose();
                    logoutWebView = null;
                }

            }

Original comment by str...@gmail.com on 8 Nov 2011 at 5:39

GoogleCodeExporter commented 8 years ago
This didn't work for me. Any other suggestions? 

Original comment by rtret...@gmail.com on 10 Nov 2011 at 11:01

GoogleCodeExporter commented 8 years ago
I'm also having issues with all of the workarounds offered.  

Only way I seem to be able to log in as a different user is to manually clear 
the Applications Cache and Local Data via Android Settings > Applications > 
Manage Applications > Downloaded > [My App]

We desperately need to be able to allow multiple users to use the application 
on a single device.

Original comment by pleri...@gmail.com on 14 Nov 2011 at 2:08

GoogleCodeExporter commented 8 years ago
For Commentors #25 and #26:

Modifying the facebookMobile.as file/library, and then adding that 
"reallyLogout" function works for me every time. 

Are you getting a specific error when you try my solution?

Original comment by str...@gmail.com on 16 Nov 2011 at 10:09

GoogleCodeExporter commented 8 years ago
Hello,
I use the Desktop API for a long time now, and it works just great. So I 
decided to use the Mobile API for one of my project on an iPad. Everything goes 
well excepted the Logout function.
I tried the "ReallyLogout" workaround but this makes the app to crash.
Has anyone tried this for iOS devices? Has anyone succeed?
Please let me know, I'm running out of ideas... :o(

Thanks,

Max

Original comment by maxime.b...@gmail.com on 17 Nov 2011 at 7:11

GoogleCodeExporter commented 8 years ago
While I tried many solutions suggested in this forum, the solution suggested in 
comment #17 worked perfectly for me. 

Now, with the additional URL passed on the logout (as see in the code snippet 
below) and the same being configured under https://developers.facebook.com/apps 
(for your app), it does force the user to provide credentials during the next 
login. Thereby, there is an opportunity to login to multiple accounts. 

FacebookMobile.logout(onLogout, 
"http://same-url-configured-for-your-fb-app.com");

Original comment by kamal.aa...@gmail.com on 27 Nov 2011 at 7:44

GoogleCodeExporter commented 8 years ago
I'm using the AS3 - Facebook Mobile API in an Adobe AIR application.
No one solution above is not working for me when I run app under device.

The problem is that when we Logout using FacebookRequest the cookies is not 
clearing in the internal device browser, as a result we have auto LogIn once we 
try to change the user.

Solution I found is to use a StageWebView ( with 0 width and height ) instead 
FacebookRequest. By using this, Facebook delete cookies in response.

Old code :

//clears cookie for mobile.
var params:Object = {};
params.confirm = 1;
params.next = appOrigin;
params.access_token = accessToken;
var req:FacebookRequest = new FacebookRequest();

openRequests[req] = handleLogout;
req.call("https://m.facebook.com/logout.php", "GET" , handleRequestLoad, 
params);

New code ( raw one without error/success handling ) :

var webView:StageWebView = new StageWebView();
webView.viewPort = new Rectangle(0, 0, 1, 1);           
webView.stage = this.stageRef;          
webView.loadURL("https://m.facebook.com/logout.php?confirm=1&next="+appOrigin+"&
access_token="+accessToken);

Hope this will help...
Успехов :)

Original comment by aromash...@gmail.com on 15 Dec 2011 at 3:20

GoogleCodeExporter commented 8 years ago
Comment #24 - works like a charm! You have few mistakes in the code (e.g. 
"this.stage" - not gonna work), but that's no big deal... 

thanks for this!

Only thing left to do is to handle all possible results and errors that might 
happen.

One more time, nice one!

Original comment by sholi...@gmail.com on 20 Dec 2011 at 10:25

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
This work for me:

function logout(e:MouseEvent):void {
 FacebookMobile.logout(onLogout, "https://m.facebook.com/dialog/permissions.request?app_id=APP_ID&display=touch&next=http%3A%2F%2Fwww.facebook.com%2Fconnect%2Flogin_success.html&type=user_agent&perms=publish_stream&fbconnect=1");
}

function onLogout(result:Object):void
{
    trace("Perfect Log Out!")
}

Remember to change your APP_ID

Original comment by dannycor...@gmail.com on 20 Mar 2012 at 2:53

GoogleCodeExporter commented 8 years ago
Comment #33 by dannycor... finally something simple that works!  Thanks!!!

(I originally thought #24 worked, but it didn't cleanup cookies, so it logged 
me back in later.  #33 actually logs me out for good!)

Original comment by jeff.w...@gmail.com on 3 Apr 2012 at 6:44

GoogleCodeExporter commented 8 years ago
can't see why #33 would work since it doesn't address the StageWebView cookies 
problem

#30 works and i use it before I make the logout call - didn't want to change 
the library code

var webView:StageWebView = new StageWebView();
webView.viewPort = new Rectangle(0, 0, 1, 1);           
webView.stage = stage;          
webView.loadURL("https://m.facebook.com/logout.php?confirm=1&next="+SITE_URL+"&a
ccess_token="+FacebookMobile.getSession().accessToken);

FacebookMobile.logout(handleLogout, SITE_URL);

Original comment by thomb...@belousov.net on 13 Apr 2012 at 10:20

GoogleCodeExporter commented 8 years ago
Ive tried all the solutions in this thread without success. The App just 
retains all the current user details.
Im attempting to implement on a Samsung Galaxy android tablet using 
FacebookMobile Graph API 1.8 

Comment 35 looks the cleanest solution, but has anyone got this to work?

My Login code is as below. Currently my logout is as per comment 35.

FacebookMobile.login(handleFaceBookLogin, stage, extendedPermissions, 
getWebView());

private function handleFaceBookLogin(session:Object, fail:Object):void {

            if (session) {  
            statusTxt.text = 'facebook login ok';
            startButtonActions();
            fbUser = FacebookMobile.getSession().user;

                /*this.user.username = fbUser.name;
                this.user.realname = fbUser.first_name +" "+ fbUser.last_name;
                this.user.deviceType = Capabilities.cpuArchitecture;
                this.user.imageURL = FacebookMobile.getImageUrl(session.uid, 'small');  
                */
                fbUsername = fbUser.name;
                fbUserFirstname = fbUser.first_name;
                fbUserId = fbUser.id;
                fbUserEmail = fbUser.email;
                fbLoggedIn = true;

                showConfirm();
            //FacebookMobile.api("/me", onFBGetUser);

            } else {
                fbLoggedIn = false;// we don't need to do this again technically, but it's good to confirm
                //error.visible = true;
                toggleResetButton('show');
                init();
            }

        }
}

Original comment by neilmill...@googlemail.com on 17 Jul 2012 at 1:24

GoogleCodeExporter commented 8 years ago
Thank you #33 works for playbook

Original comment by gustav...@gmail.com on 8 Aug 2012 at 5:26

GoogleCodeExporter commented 8 years ago
Wow... How did you figured that out dannycor...? Works for me as well.

Original comment by Radoslaw...@gmail.com on 9 Aug 2012 at 4:13

GoogleCodeExporter commented 8 years ago
Not one of these solutions alone worked on my Asus Transformer, but comment #18 
is correct, in that you need to do both logout methods to get it to work.
I combined #33 with #35 and finally got it to work!
Here's a snippet of the combined code:

function logout(appOrigin:String, appID:String, accessToken:String):void
{
     var facebookWebView:StageWebView = new StageWebView();
     facebookWebView.viewPort = new Rectangle(50,50,0,0);           
     facebookWebView.stage = FlexGlobals.topLevelApplication.stage;         
     facebookWebView.loadURL("https://m.facebook.com/logout.php?confirm=1&next="+appOrigin+"&access_token="+accessToken);           

     var url:String = "https://m.facebook.com/dialog/permissions.request?app_id="+appID+"&display=touch&next=http%3A%2F%2Fwww.facebook.com%2Fconnect%2Flogin_success.html&type=user_agent&perms=publish_stream&fbconnect=1";
     FacebookMobile.logout(logoutHandler, url);
}

//get accessToken from the LOGIN method
function loginHandler(success:Object,fail:Object):void
{
  if(success) accessToken = success.accessToken;
}

Good luck to anyone still struggling!

Original comment by kelseyja...@gmail.com on 21 Aug 2012 at 8:21

GoogleCodeExporter commented 8 years ago
it's useful thanks

Original comment by roger110...@gmail.com on 14 Jan 2013 at 2:30

GoogleCodeExporter commented 8 years ago
@39, thanks, your help have been very useful for me

Original comment by joan.mar...@gmail.com on 14 Aug 2013 at 4:17

GoogleCodeExporter commented 8 years ago
I use GraphAPI_1_8_1(FacebookGraphAPIDesktop)
In com.facebook.graph.FacebookDesktop(.as)

params.next = 
"http://static.ak.fbcdn.net/connect/xd_proxy.php#origin="+(appOrigin?appOrigin:"
");

You must change to...

params.next = appOrigin; //or params.next = "http://www.facebook.com/";

It work to delete the cookie as well.

Original comment by pic.morakot on 27 Mar 2014 at 10:41

GoogleCodeExporter commented 8 years ago
#39 It also work with my device Samsung Galaxy S3.
Thank you.

Original comment by khath.kh...@gmail.com on 2 Apr 2014 at 6:52

GoogleCodeExporter commented 8 years ago
Hi, the solution #24 works fine, but you need modify the FacebookMobile.as, my 
solution is little bit different but works really good.

I attached FacebookMobile.as and you can see the solution, you need set 
FacebookMobile.manageSession=false, when you want logout call 
FacebookMobile.reallyLogout(stage);

Original comment by jr8...@gmail.com on 9 Jun 2014 at 3:22

Attachments: