Laravel Socialite Facebook 错误:“POST https://graph.facebook.com/oauth/access_token 导致‘400 错误请求’"
问题描述
我已经使用 Laravel Socialite
为 Facebook 进行了社交登录,并且运行良好.我没有改变任何东西,现在它不起作用.尝试登录时显示此错误:
I've made social login using Laravel Socialite
for facebook and it was working fine. I haaven't changed anything and now it's not working. It shows this error when trying to login:
客户端错误:
POST https://graph.facebook.com/oauth/access_token导致
400 Bad Request响应:{"error":{"message":"此 IP 无法向该应用程序发出请求.","type":"OAuthException","code":5,"fbtrace_id":"D(已截断...)
Client error:
POST https://graph.facebook.com/oauth/access_tokenresulted in a
400 Bad Requestresponse:
{"error":{"message":"This IP can't make requests for that application.","type":"OAuthException","code":5,"fbtrace_id":"D (truncated...)
我没有更改 Facebook 应用程序中的设置,也没有更改我的代码.我的代码如下:
I haven't changed setting in my facebook app, nor in my code. My code is the following:
问题出现在这一行的 handleProviderCallback
方法中:
Problem appears in handleProviderCallback
method in this line:
$user = Socialite::with($provider)->user();
.
当我只转储这个时:$user = Socialite::with($provider)
它显示数据,但是当它像这样用来获取用户数据时,它返回错误:
it shows data but when it is used like that to get user data it returns the error:
$user = Socialite::with($provider)->user();
在 config/services.php
中,我设置了如下示例:
In config/services.php
I've set settings like this example:
在我的 facebook 应用程序中,我在设置中进行了设置:
In my facebook app I've set in settings:
应用域:my-example-domain,隐私政策网址:http://my-example-domain/my-site/,网站网址:http://my-example-domain/my-site/handleProviderCallback/facebook,有效的 OAuth 重定向 URI:http://my-example-domain/my-site/handleProviderCallback/facebook
推荐答案
是的,我根本没有检查请求以查看返回的内容,但是 Larachat 上有人帮我解决了这个问题.
Yeah, I didn't check the request at all to see what's returned but someone on Larachat helped me solve this problem.
在获取用户并处理请求之前,我所要做的就是在回调方法中添加以下代码:
All I had to do before getting the user and handle the request was to add the following code in the callback method:
这篇关于Laravel Socialite Facebook 错误:“POST https://graph.facebook.com/oauth/access_token 导致‘400 错误请求’"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!