Skip to content

Instantly share code, notes, and snippets.

@nicdev
Last active October 31, 2024 12:14
Show Gist options
  • Select an option

  • Save nicdev/7dab5d9c4784b3beb93cf5219daca55c to your computer and use it in GitHub Desktop.

Select an option

Save nicdev/7dab5d9c4784b3beb93cf5219daca55c to your computer and use it in GitHub Desktop.
Log in with LinkedIn OpenID Laravel Socialite example
Route::get('/auth/linkedin', function () {
return Socialite::driver('linkedin-openid')
->scopes(['openid', 'profile', 'email'])
->redirect();
});
Route::get('/auth/linkedin/callback', function () {
$user = Socialite::driver('linkedin-openid')->user();
dd($user);
/*
Laravel\Socialite\Two\User {#681▶
+id: "..."
+nickname: null
+name: "Nic Rosental"
+email: "...@gmail.com"
+avatar: "https://media.licdn.com/dms/image/.../profile-displayphoto-shrink_100_100/0/1626097343670?e=1711584000&v=beta&t=K6ZJvC6RjBov-9vJwlQNJCDYNH1dAlGdJYkwdHS7A_A"
+user: array:6 [▶]
+attributes: array:8 [▶]
+token: "..."
+refreshToken: null
+expiresIn: 5183999
+approvedScopes: array:1 [▶
0 => "email,openid,profile"
]
}
*/
});
@nicdev
Copy link
Author

nicdev commented Jan 21, 2024

The Log in with LinkedIn feature was deprecated in late '23 in favor of OpenID.
Unfortunately the documentation on LI's side is lacking. If you try to use scopes like r_emailaddress you'll get a "Bummer..." error which is pretty unhelpful. I hope this gist saves you some time. Just use the linkedin-openid provider instead of plain linkedin.

@MBarti
Copy link

MBarti commented Oct 30, 2024

thank you! It helped me.

@nicdev
Copy link
Author

nicdev commented Oct 31, 2024

thank you! It helped me.

Glad to hear it! I hope you didn't waste as much time as is did 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment