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 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