简体   繁体   English

Windows Phone 8 Facebook身份验证

[英]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. 我正在开发一个Windows Phone 8应用程序,我想让用户使用他们的Facebook帐户登录,这样他们就不必在我的应用程序上创建一个帐户。

I saw the Facebook SDK for .NET and decided to use it because it seems to be really efficient and popular. 我看到Facebook SDK for .NET并决定使用它,因为它似乎非常高效和受欢迎。

As a beginner, I followed the tutorial in the doc of the SDK : http://facebooksdk.net/docs/phone/tutorial/ 作为初学者,我按照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. 我点击了登录按钮,我被重定向到教程中他们称之为“FacebookLoginPage”(带有空网格的.xaml,因此webbrowser可以放入其中),然后出现带有Facebook页面的webbrowser,我可以输入我的登录名和密码。 After that, I'm redirected to the page that asks for permissions on my Facebook account, I click on OK. 之后,我被重定向到要求我的Facebook帐户权限的页面,我点击确定。 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... 我应该被重定向到教程中他们称之为“LandingPage”的内容,但不是我将其重定向到显示的“login_success”( https://www.facebook.com/connect/login_success.html ) “成功”还有安全警告,然后再也没有发生......

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. 所以我试着运行他们在网站文档中提供的示例应用程序,我刚刚修改了它的Facebook AppID(我已经把它放了),同样的事情发生了。 I also tried other things that I found on the Nokia Developer Wiki, same thing. 我也尝试过在诺基亚开发者Wiki上找到的其他东西,同样的事情。

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 ? 所以我认为我的Facebook应用程序有问题,但我找不到它是什么......有人可以给我一些帮助吗? 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 更新:我终于按照本教程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. 重定向到“ https://www.facebook.com/connect/login_success.html ”应该包含accessToken作为url参数,因此如果您允许导航到此URL,则确实存在安全风险,因为它暴露了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. 您需要从WebBrowser控件中侦听“导航”事件,如果浏览器导航到“ https://www.facebook.com/connect/login_success.html ”,则需要取消导航并获取AccessToken来自url参数。

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 "?" 更新:看起来FB改变了他们的OAuth登录响应... login_success.html#access_token = to ... login_success.html?#access_token =现在有一个“?” 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. 我最近在商店的很多应用程序中看到了这一点,所以可能不是你做错了什么,而是Facebook的改变还没有在SDK中反映出来。

Have you tried using Windows Azure Mobile Services Authentication instead? 您是否尝试过使用Windows Azure移动服务身份验证?

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. 请参阅http://www.windowsazure.com/en-us/develop/mobile/how-to-guides/register-for-facebook-authentication/http://www.windowsazure.com/en-us/上的指南。开发/移动/如何指南/注册Facebook认证/了解更多信息。

I'm using the LoginButton control of the Facebook SDK .NET for WindowsPhone and have the same issue. 我正在使用面向WindowsPhone的Facebook SDK .NET的LoginButton控件并遇到同样的问题。

I Fix it, downloading the project from github Facebook-WinClient-Sdk and changing the line 186 of FacebookSessionClient class, for this one: 我修复它,从github Facebook-WinClient-Sdk下载项目并更改FacebookSessionClient类的第186行,为此:

Uri endUri = new Uri(" https://m.facebook.com/connect/login_success.html?#access_token "); 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! facebook sdk for .net的团队肯定会解决这个问题,但我今天有一个演示,需要它才能运行!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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