The facebook app uses the facebook browser after login instead of your current browser, so is unaware of previous state. I was only experiencing this error when logging in via mobile web with the facebook app instead of facebook in browser. Click on select a project in the left side of navigation which would show a modal where you’re expected to create a project from. It took me hours to realize that I happened to be calling $provider->user() multiple times, when I should have called it just once and saved the result to a variable. Unless you disable session state verification (as other answers here seem to want you to do but not everyone will want to do), $provider->user() can only be called once per request because the inside of that function calls hasInvalidState(), which then removes the 'state' entry from the session.It took me ~12 hours one time to realize that I hadn't added a new field to the $fillable array in the model. Sometimes InvalidStateException is a red herring and the true root cause is some other bug.Solution 4 There are 2 major "gotchas" that none of the existing answers address. Possible uses include redirecting the user to theĬorrect resource in your site, and cross-site-request-forgery Server round-trips this parameter, so your application receives the Provides any state that might be useful to yourĪpplication upon receipt of the response. Return ! (strlen($state) > 0 & $this->request->input('state') = $state) įor instance, state is very useful to pass data throught google: Return false // request->getSession()->pull('state') * Determine if the current request / session has a mismatching "state". * Indicates that the provider should operate as stateless. * Indicates if the session state should be utilized. I think Socialite is already prepared to avoid this issue. If you need to read a given parameter state returned by a thirdparty service, you can set Socialite to avoid this checking with the stateless method: Socialite::driver($provider)->stateless() Send a request to api for the url to fetch the code: Socialite::with ('facebook')->stateless ()->redirect ()->getTargetUrl () Then make a request with the above fetched url, which redirects with the code parameter. Resolved : Socialite::driver('google')->stateless()->user() Since I'm doing the request over an API, I take the following steps. After 'php artisan cache:clear' and 'composer dump-autoload', I can login with no issue from both and īe sure to delete your cookies from browser when testing it after these modifications are done.The default configuration is 'domain' => null, I made a change to 'domain' => ''. Go to your www root, check the laravel file config/session.php.At first I think my issue is random until I've got the clue by Chris Townsend's reply to the question - Thank you very much. It seems to be the same as your issue.įurthermore I found my issue occurs when I open my site without - no problem. In the function handleProviderCallback() when it re-direct back from Facebook login. InvalidStateException in AbstractProvider.php line 182 I ran into this issue last night and solve it with the following solution.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |