Hey Folks I'm trying the Laravel Socialite Package to allow users to log in with their LinkedIn account. I have already set the Client ID, Secret, and URL In my ENV File as follows:
LINKEDIN_CLIENT_ID=xyzSomeID LINKEDIN_CLIENT_SECRET=xyzSomeSecret LINKEDIN_URL=https://mydomainname.com/api/domain-login/linkedin/callback
But When I try to hit the login with the LinkedIn button I get the following error
Unauthorized scope error scope profile is not authorized for your application LinkedIn Socialite login Laravel
And after a few seconds, I was redirected back to the URL with the following error
{"message":"Error occurred","data":"Client error:
POST https://www.linkedin.com/oauth/v2/accessTokenresulted in a
400 Bad Request response:\n{\"error\":\"invalid_request\",\"error_description\":\"A required parameter \\\"code\\\" is missing\"}\n113"}
Please Note: Sign-in with LinkedIn using OpenID Connect is already enabled.
Any Hint in this regard will be highly appreciated.
I have already set up the routes which are working fine. The developer console is already set up and working fine. The client ID, Secret and Call back URI are already added in the ENV file.
Here is my route:
Route::get('domian-login/{provider}', [ControllerName::class, 'redirectToProvider']); Route::get('domain-login/{provider}/callback', [ControllerName::class, 'handleProviderCallback']); Route::post('domain/save-social-user', [ControllerName::class, 'saveSocialUser']);
I was able to resolve this issue. The main problem is that now LinkedIn is using Sign In with LinkedIn using OpenID Connect instead of Sign In with LinkedIn.
This is what I found in the root code of laravel/socialite.
So you just need to use linkedin-openid instead of linkedin in the service.php
and Socialite::driver('linkedin-openid')->redirect();
.