0

I use Socialite 2.0 and Laravel 5.2.39. The social login on localhost:8000 is working properly but It doesn't work on the production site (example.com).

public function handleProviderCallback($provider) { $social_user = Socialite::driver($provider)->user(); .... }

The exception error when call Socialite::driver($provider)->user() function is:

InvalidStateException in AbstractProvider.php line 199

I tried all solutions people suggested but no luck. Here is some configuration

SESSION_DRIVER=file DOMAIN=example.com URL=http://example.com (used in config/app.php) DOMAIN=mysite.com (used in config/session.php)

Here are the routes:

Route::get('redirect/{provider}', 'Auth\AuthController@redirectToProvider'); Route::get('callback/{provider}', Auth\AuthController@handleProviderCallback');

Thanks for helping!

metylbk
  • 131
  • 1
  • 1
  • 11
  • If I use Socialite::driver($provider)->stateless()->user(), an other error occurs: ``ClientException in RequestException.php line 107: Client error: `POST https://graph.facebook.com/oauth/access_token` resulted in a `400 Bad Request` response: {"error":{"message":"Missing authorization code","type":"OAuthException","code":1,"fbtrace_id":"EamBm42\/suf"}}`` – metylbk Jun 24 '16 at 04:21
  • Finally I found the solution. It's related to Nginx configuration. Use `try_files $uri $uri/ /index.php$is_args$args;` instead of `try_files $uri $uri/ /index.php$query_string;` on file /etc/nginx/sites-available/. – metylbk Jul 01 '16 at 07:52
  • Man, you juste saved my life ! Put it as an answer, this problem touch a lot of people. – Vincent Decaux Nov 18 '16 at 11:58

1 Answers1

0

Finally I found the solution. It's related to Nginx configuration. Use try_files $uri $uri/ /index.php$is_args$args; instead of try_files $uri $uri/ /index.php$query_string; on file /etc/nginx/sites-available/.

metylbk
  • 131
  • 1
  • 1
  • 11