Localhost facebook登录不适用于较低级别的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.
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.
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.
The problem comes when I try to use another redirect uri like http://localhost/myapp/user_controller/register
(Adds the user to the database). 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).
I figured out that, to solve this problem for a while, I have to go to the facebook app page: 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.
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.
Thanks again.
提前感谢您的阅读。 p>
我一直在与Facebook合作 登录(php和javascript sdk方法)已经有几年了,我正面临着我正在开发的新应用程序的特殊问题。 p>
我的localhost配置为app 虚拟目录如下: p>
http:// localhost / myapp /
code> pre>
在Facebook上,进行以下设置 我的应用程序指向该URL:App域,Facebook登录网站,Facebook上的应用程序(https和http)和移动Web。 p>
当我执行登录过程并将redirect_uri指向 http:// localhost / myapp / code>,它工作正常,cookie已设置,我可以对图形api进行查询。 p>
当我出现问题时 尝试使用另一个重定向uri,如 http:// localhost / myapp / user_controller / register code>(将用户添加到数据库)。 虽然它位于Facebook上配置的应用程序URL中,但SDK会输出错误消息(OAuthException |必须使用活动访问令牌来查询有关当前用户的信息。| Code 2500)。 p>
我想出来,要解决这个问题一段时间,我必须去facebook应用页面:apps.facebook.com/myapp。 每次我的access_token过期时我都必须这样做,因为这个应用程序不打算在facebook里面,我认为这不是解决这个问题的最佳方法。 p>
I 希望我们能够找到解决这个问题的好方法,这个问题可以帮助未来的开发人员。 p>
我正在使用CodeIgniter(我已经使用了大约一年)和Facebook PHP SDK (直接从github官方仓库下载)作为CI库。 p>
再次感谢。 p>
div>
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
.