I am trying out the "reject" workflow when a user cancels the OAuth Authorization request from the Social (LinkedIn in this case) page
ClientException in RequestException.php line 111: Client error:
POST https://www.linkedin.com/oauth/v2/accessToken
resulted in a400 Bad Request
response: {"error":"missing_parameter","error_description":"A required parameter \"code\" is missing"}
Controllers have the standard code:
public function redirect()
{
return Socialite::driver('linkedin')->redirect();
}
public function callback()
{
$providerUser = Socialite::driver('linkedin')->user();
...
}
It works fine if the user clicks Allow/Accept on the social site. It throws exception when the user cancels.
I am unable to figure out how to handle the user's "Reject" scenario.
In the
callback
function add atry
catch
block for exception and do whatever you like to do.