Windows Phone 8 Facebook SDK for .NET Logout - facebook

I was able to successfully login to Facebook and get required permissions for my Windows Phone 8 application using the tutorial here -
http://facebooksdk.net/docs/phone/controls/login-ui-control/
Now, the login button control opens up a browser window and asks the user to login.
Then the user logins and grants permissions to my app.
Then the user is redirected back to my app on the phone and sees the login button changed to logout button.
When the user will click on the logout button, the session data is removed from the loginbutton control. So my app sees the user as logged out.
But when the user logs in again, he is not asked for his credentials and is directly logged in to his account - this is because the user actually never logged out of the web browser window in the Windows Phone application.
So how do I logout the user from the browser control in my Windows Phone 8 application.
All help is greatly appreciated!

The user is not asked for his credentials because the Facebook authentication cookie is still present in the WebBrowser control.
So to completely logout the user from Facebook, you need to clear the WebBrowser cookies.
Unfortunately, there is no easy way for erasing cookies on Windows Phone 7.
On Windows Phone 8 you just need to call ClearCookiesAsync:
await new WebBrowser().ClearCookiesAsync();
Here is a tutorial that makes use of it: http://www.developer.nokia.com/Community/Wiki/Integrate_Facebook_to_Your_Windows_Phone_Application

Related

Third party authentication doesn't work from facebook browser

I have a web application (React js with Kotlin backend) that has normal email + pw (plus PIN) login, and it also supports 3rd party authentication (Google and Facebook). It works on mobile and web, however, when I open my webpage through Facebook app - which opens it's own browser - and try to log in with 3rd party authentication, I can click on that "Continue as me" button, but then the page refreshes and I'm not logged in. I saw the same thing happen on other sites too, e.g. Figma, Pinterest, etc. I thought it's impossible to log in this way anymore, however, I just noticed that you can actually log in to Stackoverflow this way (so facebook app -> facebook browser -> stack overflow -> 3rd party auth and it works).
Has anyone figured it out how it was possible for Stackoverflow to do this?
Ok, I found the solution. The problem was that when a user clicked on 'Login with FB' button on my site, I sent a request to fb to get back a content of a login window and I created a pop up window where I rendered it, I put on a listener on that pop up window and once it was done, then I got the access token and sent it to backend and logged the user in. On a normal browser it works perfect (both pc and mobile) but as I mentioned above it didn't work in an in app browser like facebook app.
The issue was that facebook app opens a website in it's own browser that doesn't handle any pop ups, so after a successful authentication I saw that nothing happened and it was because we were not redirected to the original window where we should have, and it had the token in the url. So the solution was instead of making this pop up window for FB login, just redirect the user to the fb login page (and stay on the same window), and once the login is successful, just handle the token as is.

How to retrieve Logged In User’s Credentials from device

I have a login page in my Ionic App. The current behavior of the app is as below:
After downloading the app, User launches it.
The app shows Login Options (buttons) page (right now, I only have Microsoft (Azure Active Directory)).
Tapping any of the options, the app asks for login credentials (email and password).
The app authenticates these credentials against the server/corresponding vendors.
Upon successful authentication, the user is taken to Home Page of the app.
Now the important part, for all the subsequent launches, when the user taps on the 'Microsoft' (again, this is the only option I have right now) button it doesn't ask for credentials (emails ID and password). Instead it takes the User to Home Page directly.
So, I am sure the user credentials and/or its corresponding token or something similar is being maintained in the device somewhere.
How do I access this information programmatically?
What I am trying to achieve is: If the user credentials/token already exist on the device then don't even shot the Login Options Page. Take the user to the Home Page directly after the app is launched.
Any ideas/pointers/suggestions on how this can be done.
Thank you!

Facebook sdk4 php switch User feature

I am developing a site to manage Facebook Feeds and is using facebook-php-sdk-v4-4.0-dev.I have the user Login and access token saved to database functionality working properly.
I need to show Switch Facebook User account Option, If he is already logged into facebook account. Currently if he is logged into facebook account on another tab. There will not be facebook authentication, It just shows App Permissions window and then completes facebook login process.
But I found that this option is available in Facebook Login for the Web with the JavaScript SDK example...A pop up come up for Login and you can switch user on top right side.
Please let me know how to accomplish this in PHP sdk 4 or work around, or am I missing something here.
Thanks in advance....
Please see this screenshot
https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-xpf1/t39.2178-6/10574702_711575178930859_1600770327_n.png
I have added a screenshot where JavaScript SDK show switch user button (top right side)when user is logged in to facebook account in another browser tab.(this comes up as pop up)
But there is no such option when using php sdk. instead of pop up, its come as a webpage and it does not have switch user account.

Mobile Website Facebook Login using Facebook App for login details

Using a web browser e.g. Chrome on Android, if a mobile website requires a user to be logged in to Facebook and they are not, the browser will ask for Login details even though the phone may be logged in to Facebook via the Facebook native App. Is there any way to get details from the Facebook App without the user having to log in again?
If you want to login in website in a browser, using Facebook account from Facebook app - it is impossible, without intermediary application, or service. And even with it, I don't think, that you can get user login data.
Other approach - is try to launch Facebook app from your site, and show site from it, but again, you can't login to it, using app.
Why? Because the app, holds only token data, and nothing more. You can't get other information, like password, or email. Also, the work of browser, that save cookies and the app, that save token is different. You can't connect them together.
Clearly speaking it is not possible using website in browser.
Even it is also not possible if you develop any android app, the reason is that the facebook app will not share any data to any other app (even if it is running on the same device).
I also don't think that launching the facebook app from browser will be feasible for you, as you just want to use the facebook login system and then want the users back on your website (and again facebokk will not send any data to your web or app even if it is launched from your web or app).
I think it's not possible, because we wont link browser and an app.
I developed one android app with facebook login integration.If facebook native app already logged in, now i click my app facebook login button it directly redirect my app to my home page without asking fb username and password.
For me i used localStorage in javascript
localStorage.setItem("userName", userName);
localStorage.setItem("password", password);
var uname=localStorage.getItem('userName');
var pass=localStorage.getItem('password');

Connecting the login flow between Android/iPhone app and the web

When the person opens my app, I want to display a button. The user clicks this button, and it opens a browser (embedded, of course) inside the app, allowing the user to LOGIN through that web page.
Of course, when the person logs in, it only logs in to that web server. The web service now knows that the user is logged in.
As the user uses my mobile app, I need to know if he's logged in or not. How can I know? There's no way for my app to determine if the user is logged into my web service.
By the way, I am using Django framework for my web service.
Well, presumably when your user logs in the server is telling their browser to set a cookie. Why not just capture this cookie and use it to determine if they successfully logged in?