简体   繁体   English

Localhost Facebook登录名不适用于较低级别的网址

[英]Localhost facebook login not working for lower level of the url

Thanks in advance for reading. 在此先感谢您的阅读。

I've been working with facebook login (both php and javascript sdk methods) for a couple of years and I'm facing a particular problem with new apps I'm developing. 我已经使用Facebook登录(php和javascript sdk方法)已有两年了,而我正在开发的新应用程序正面临一个特殊的问题。

I have an app in my localhost configured as virtual directory as follows: 我的本地主机中有一个配置为虚拟目录的应用程序,如下所示:

http://localhost/myapp/

On facebook, the following settings of my app are pointing to that url: App Domains, Facebook Login Website, App on Facebook (https and http) and Mobile Web. 在facebook上,我的应用程序的以下设置指向该url:应用程序域,Facebook登录网站,Facebook上的应用程序(https和http)和Mobile Web。

When I do the login process and point the redirect_uri to http://localhost/myapp/ , it works fine, the cookie is set and I can make queries to the graph api. 当我执行登录过程并将redirect_uri指向http://localhost/myapp/ ,它工作正常,设置了cookie,并且可以查询图形api。

The problem comes when I try to use another redirect uri like http://localhost/myapp/user_controller/register (Adds the user to the database). 当我尝试使用另一个重定向uri(例如将http://localhost/myapp/user_controller/register (将用户添加到数据库))时,就会出现问题。 Although it is inside the app url configured on facebook, the SDK outputs an error message (OAuthException | An active access token must be used to query information about the current user. | Code 2500). 尽管它位于facebook上配置的应用程序URL中,但SDK会输出一条错误消息(OAuthException |必须使用活动访问令牌来查询有关当前用户的信息。|代码2500)。

I figured out that, to solve this problem for a while, I have to go to the facebook app page: apps.facebook.com/myapp. 我发现,要解决此问题一段时间,我必须转到Facebook应用程序页面:apps.facebook.com/myapp。 I have to do it everytime my access_token has expired and, since this app is not intended to be inside facebook, I don't think that this is the best way to solve this. 每当我的access_token过期时,都必须执行此操作,并且由于该应用程序不适合在Facebook内部使用,因此我认为这不是解决此问题的最佳方法。

I hope together we can find a good way to solve this issue and this questions helps future developers. 我希望我们在一起可以找到解决此问题的好方法,并且这个问题对将来的开发人员有帮助。

I'm using CodeIgniter (which I've been using about a year) and Facebook PHP SDK (downloaded directly from the github official repo) as CI library. 我正在使用CodeIgniter(我已经使用大约一年了)和Facebook PHP SDK(直接从github官方仓库下载)作为CI库。

Thanks again. 再次感谢。

At no point would you get that error during authentication. 在身份验证期间,您绝不会收到该错误。

I'm pretty sure that you instead have an error in your code that fails to exchange the code for the access_token on the .../register endpoint, and so you end up using an invalid access_token . 我很确定您会在代码中出现错误,导致无法在.../register端点上交换access_tokencode ,因此您最终使用了无效的access_token

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

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