I'm following the Socialite github documentation, and the controller method below works just fine if the user successfully logs in with Facebook and grants my app access.
public function handleProviderCallback()
{
$user = Socialite::driver('facebook')->user();
dd($user);
// $user->token;
}
However, how do I know if a user selected "Cancel" when Facebook asks for the user's permissions?
Currently, I receive the error below after I click "Cancel" on the Facebook page that asks for my permission to share my info with the app:
ClientException in RequestException.php line 111:
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":"H75M4eMC+1f"}}
I updated my code to the following, which did the trick: