简体   繁体   中英

Windows Phone 8 Facebook Authentication

I am working on an application for Windows Phone 8 and I'd like to give the possibility to the users to login with their Facebook account, so they won't have to create an account on my application.

I saw the Facebook SDK for .NET and decided to use it because it seems to be really efficient and popular.

As a beginner, I followed the tutorial in the doc of the SDK : http://facebooksdk.net/docs/phone/tutorial/

I did the exact same thing that in the tutorial, everything is okay since I login. I click on the login button, I'm redirected to what they call the "FacebookLoginPage" in the tutorial (a .xaml with an empty grid so the webbrowser can fit in it), then appears the webbrowser with the Facebook page where I can type my login and password. After that, I'm redirected to the page that asks for permissions on my Facebook account, I click on OK. Everything is good so far.

And then comes my problem. I should be redirected to what they call the "LandingPage" in the tutorial, but instead of that I'm redirected to the facebook "login_success" ( https://www.facebook.com/connect/login_success.html ‎) which displays "Success" and also a security warning, and then nothing happens anymore...

I thought something in my code was not right so I spend a couple of hours working on it, didn't find anything. So I tried to run the sample application that they provide in the doc of the website, I just modified the Facebook AppID in it (I've put mine), and same thing happened. I also tried other things that I found on the Nokia Developer Wiki, same thing.

So I think something is wrong with my Facebook Application, but I can't find what it is... Is anybody could give me some help ? I'm dying here :(

I apologize in advance for my english mistakes, and I wish you a good day !

UPDATE : I finally did it following this tutorial http://developer.nokia.com/Community/Wiki/Integrate_Facebook_to_Your_Windows_Phone_Application

The redirect to " https://www.facebook.com/connect/login_success.html ‎" should contain the accessToken as a url parameter, so if you allow navigating to this url it is indeed a security risk as it exposes the AccessToken. You need to listen for the 'Navigating' event from the WebBrowser control and if the browser is navigating to " https://www.facebook.com/connect/login_success.html ‎" then you need to cancel the navigation and get the AccessToken from the url parameter.

UPDATE: It looks like FB changed their OAuth login response from ...login_success.html#access_token= to ...login_success.html?#access_token= There is now a "?" character before the "#" character.

I've seen this in a lot of apps in the store recently so it's probably not you doing something wrong but rather a change by Facebook which hasn't yet been reflected in the SDK.

Have you tried using Windows Azure Mobile Services Authentication instead?

See guides at http://www.windowsazure.com/en-us/develop/mobile/how-to-guides/register-for-facebook-authentication/ and http://www.windowsazure.com/en-us/develop/mobile/how-to-guides/register-for-facebook-authentication/ for more information.

I'm using the LoginButton control of the Facebook SDK .NET for WindowsPhone and have the same issue.

I Fix it, downloading the project from github Facebook-WinClient-Sdk and changing the line 186 of FacebookSessionClient class, for this one:

Uri endUri = new Uri(" https://m.facebook.com/connect/login_success.html?#access_token ");

The team of facebook sdk for .net will be fix this issue for sure, but i have a demo today and need it works!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM