Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

shakircs's avatar

Laravel Socialite Issue

Hi, I have a query with Laravel Socialite Package.

I am facing problem only for LinkedIn as it was working fine before.

Getting problem when LinkedIn remove auth1 support. I am using laravel 5.8 version with 4.1 socialite.

I got following error message

Client error: POST https://www.linkedin.com/oauth/v2/accessToken resulted in a 400 Bad Request response: {"error":"invalid_request","error_description":"A required parameter "code" is missing"}

Thanks

0 likes
17 replies
shakircs's avatar

I am unable to put all code here. There is no attachment option

timmy1420's avatar

Did anyone find a solution yet? Out of 100 user, this error happens only to some linkedin accounts which are registered in our database

onatcer's avatar

If someone comes across this thread and is wondering: I'm not 100% sure if it's the only cause but this definitely happens if a user cancels the Linkedin Login. The user gets redirected back. After that laravel tries to issue an Request but has no code so the API Error appears.

Easy fix is to just try/catch the Socialite::driver('linkedin')->user();

binbee13's avatar

Hi, Please let me know anyone fixes this issue. I am getting the same error Client error: POST https://www.linkedin.com/oauth/v2/accessToken resulted in a 400 Bad Request response: {"error":"invalid_request","error_description":"A required parameter "code" is missing"}

ahmednawazbutt's avatar

@onatcer

That does not work for me. here is my code

$provider = Socialite::driver($provider);
        try{
            $user = $provider->user();
        }
        catch (ClientException $ex){
            // echo $ex->getMessage();exit;
            return redirect()->route('login');
        }
        catch (InvalidStateException $ex){
            // echo $ex->getMessage();exit;
            return redirect()->route('login');
        }
yahyaya's avatar

make sure you activated the

Sign In with LinkedIn (product)

3 likes
iffikhan's avatar

@yahyaya It is depricated and new product in "Sign In with LinkedIn Using OpenID Connect"

fhyfr's avatar

Try this tutorial, it's work for me. I'm sorry i can't include the link because i'm already sign up Laracast today. You can found the tutorial in your search engine using keyword "How to Get SignIn with LinkedIn to work" with author Taric A. as a product manager from LinkedIn.

The main problem is beacuse you haven't activated "Sign In with LinkedIn" product on your application.

iffikhan's avatar

I have the same problem. guide me if you have any solution

arshman's avatar

if someone use "Sign In with LinkedIn Using OpenID Connect" in Laravel please guide us.

MohammedAmineELHARCHI's avatar

@iffikhan you should update your services in config/services.php to 'linkedin-openid' => [...] also the redirect function : return Socialite::driver('linkedin-openid')->redirect(); it works for me

2 likes
waseemakram's avatar

User Driver Provider name (linkedin-openid) return Socialite::driver('linkedin-openid')->scopes(['w_member_social','openid','profile','email'])->redirect();

Note: In scopes use scope parameter from your linkedin account

same as change in config/services.php if you use provider name (linkedin) change to (linkedin-openid) 'linkedin-openid' => [ 'client_id' => env('LINKEDIN_CLIENT_ID'), 'client_secret' => env('LINKEDIN_SECRET_ID'), 'redirect' => env('LINKEDIN_REDIRECT_URL'), ],

Please or to participate in this conversation.