<i id='nZD48'><tr id='nZD48'><dt id='nZD48'><q id='nZD48'><span id='nZD48'><b id='nZD48'><form id='nZD48'><ins id='nZD48'></ins><ul id='nZD48'></ul><sub id='nZD48'></sub></form><legend id='nZD48'></legend><bdo id='nZD48'><pre id='nZD48'><center id='nZD48'></center></pre></bdo></b><th id='nZD48'></th></span></q></dt></tr></i><div id='nZD48'><tfoot id='nZD48'></tfoot><dl id='nZD48'><fieldset id='nZD48'></fieldset></dl></div>
    1. <legend id='nZD48'><style id='nZD48'><dir id='nZD48'><q id='nZD48'></q></dir></style></legend>

      1. <small id='nZD48'></small><noframes id='nZD48'>

        <tfoot id='nZD48'></tfoot>

          <bdo id='nZD48'></bdo><ul id='nZD48'></ul>
      2. Laravel Socialite Facebook 错误:“POST https://graph.facebook.c

        时间:2023-07-16

        <small id='9JSlt'></small><noframes id='9JSlt'>

          <tbody id='9JSlt'></tbody>

        <i id='9JSlt'><tr id='9JSlt'><dt id='9JSlt'><q id='9JSlt'><span id='9JSlt'><b id='9JSlt'><form id='9JSlt'><ins id='9JSlt'></ins><ul id='9JSlt'></ul><sub id='9JSlt'></sub></form><legend id='9JSlt'></legend><bdo id='9JSlt'><pre id='9JSlt'><center id='9JSlt'></center></pre></bdo></b><th id='9JSlt'></th></span></q></dt></tr></i><div id='9JSlt'><tfoot id='9JSlt'></tfoot><dl id='9JSlt'><fieldset id='9JSlt'></fieldset></dl></div>
        <legend id='9JSlt'><style id='9JSlt'><dir id='9JSlt'><q id='9JSlt'></q></dir></style></legend>
        • <bdo id='9JSlt'></bdo><ul id='9JSlt'></ul>

                  <tfoot id='9JSlt'></tfoot>
                  本文介绍了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 a400 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:

                  Route::get('login', ['as' =>'getLogin', 'uses'=>'AuthAuthController@getLogin']);
                  Route::get('handleProviderCallback/{provider}', 'AuthAuthController@handleProviderCallback');

                  public function login($provider = false)
                      {
                       if(!$provider) {
                              $user = Input::all();
                              $auth_user = new AuthenticateUser();
                              $is_logged = $auth_user->findByEmailOrCreate($user, false);
                              if($is_logged) {
                  
                                  Session::put('user', Auth::user());
                                  Session::put('user_id', Auth::user()->id);
                                  Session::put('email', Auth::user()->email);
                                  Session::put('name', Auth::user()->name);
                  
                                  return redirect()->intended('dashboard');
                              }
                              return redirect('/')->withInput()->with('error', 'Wrong username or password!');
                          }
                          return Socialite::with('facebook')->redirect();
                      }
                      
                      public function handleProviderCallback($provider=false) {
                          if(Input::has('code')) {
                              $user = Socialite::with($provider)->user();
                              $auth_user = new AuthenticateUser();
                              $provider_user = $auth_user->findByEmailOrCreate($user, $provider);
                              Session::put("user", array($provider_user));
                              Session::put('user_id', $provider_user->id);
                              Session::put('email',$provider_user->email);
                              Session::put('name',$provider_user->name);
                  
                              return redirect('dashboard');
                          }
                      }

                  问题出现在这一行的 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' => [
                          'client_id' => 'my-client-id-from-fb-app', 
                          'client_secret' => 'my-secret-code-from-fb-app', 
                          'redirect' => 'http://my-example-domain/my-site/handleProviderCallback/facebook'
                      ],

                  在我的 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:

                  if (!$request->has('code') || $request->has('denied')) {
                     return redirect('/');}
                  

                  这篇关于Laravel Socialite Facebook 错误:“POST https://graph.facebook.com/oauth/access_token 导致‘400 错误请求’"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:PHP Oauth 签名_无效 下一篇:如何将 oAuth 与 Guzzle 5(或者,更好,与 Guzzle 6)一起使用

                  相关文章

                  <small id='EUj9I'></small><noframes id='EUj9I'>

                  • <bdo id='EUj9I'></bdo><ul id='EUj9I'></ul>
                  1. <tfoot id='EUj9I'></tfoot>
                    <legend id='EUj9I'><style id='EUj9I'><dir id='EUj9I'><q id='EUj9I'></q></dir></style></legend>

                      <i id='EUj9I'><tr id='EUj9I'><dt id='EUj9I'><q id='EUj9I'><span id='EUj9I'><b id='EUj9I'><form id='EUj9I'><ins id='EUj9I'></ins><ul id='EUj9I'></ul><sub id='EUj9I'></sub></form><legend id='EUj9I'></legend><bdo id='EUj9I'><pre id='EUj9I'><center id='EUj9I'></center></pre></bdo></b><th id='EUj9I'></th></span></q></dt></tr></i><div id='EUj9I'><tfoot id='EUj9I'></tfoot><dl id='EUj9I'><fieldset id='EUj9I'></fieldset></dl></div>