Social login with google/facebook via Laravel API

A passionate full-stack developer from @ePlus.DEV
Search for a command to run...

A passionate full-stack developer from @ePlus.DEV
No comments yet. Be the first to comment.
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling.
Laravel's factory system introduces the recycle method, allowing efficient reuse of model instances across multiple factory calls. This feature is particularly valuable when creating complex data structures with shared relationships. // Basic recycli...
Daily Tech Brief — 06/08/2026 Một bản tin giúp Developer cập nhật nhanh AI, Cloud, Open Source và những công nghệ đáng chú ý trong ngày. 📌 Executive Summary Claude Code 2.1.223 vá nhiều đường обх

Overview In a challenge lab you’re given a scenario and a set of tasks. Instead of following step-by-step instructions, you will use the skills learned from the labs in the course to figure out how to

🏕️ Arcade Base Camp August 2026 Welcome to Arcade Base Camp August 2026, where you’ll develop key Google Cloud skills and earn an exclusive credential that will open doors to the cloud for you. No pr

Một bản tin giúp Developer cập nhật nhanh AI, Cloud, Open Source và những công nghệ đáng chú ý trong ngày. 📌 Executive Summary Google Cloud giới thiệu hai Database Operations Agents hỗ trợ onboard

Một bản tin giúp Developer cập nhật nhanh AI, Cloud, Open Source và những công nghệ đáng chú ý trong ngày. 📌 Executive Summary SK hynix và Sandisk công bố đặc tả mở đầu tiên cho High Bandwidth Fla

public function handleProviderCallback(Request $request, $provider){
$loginService = new LoginService(); // Don't forget to import the LoginService.php at top
if($loginService->isLoginWithGoogle($provider)) {
$response = Http::get("https://www.googleapis.com/oauth2/v3/tokeninfo?id_token={$accessToken}");
if (!$response->successful()) {
throw new \Exception($response->body(), requestResponse()::UNAUTHORIZED_ACTION);
}
$socialProvider = json_decode($response->body(), true);
// Your Logic Here
}
// Facebook
if($loginService->isLoginWithFacebook($provider)) {
$response = Http::get("https://graph.facebook.com/v21.0/me?fields=id,name,email&access_token={$accessToken}");
// When it's failed to successful
if (!$response->successful()) {
throw new \Exception($response->body(), requestResponse()::UNAUTHORIZED_ACTION);
}
$socialProvider = json_decode($response->body(), true);
// Your Logic Here
}
} // handleProviderCallback method closing
// LoginService.php
public function isLoginWithGoogle($data){
return $data == "google"; // returning true/false
}
public function isLoginWithFacebook($data){
return $data == "facebook"; // returning true/false
}
Important Note: $provider is a dynamic parameter which is receiving "facebook","google", "twitter","LinkedIn" etc from the URL.
Note: Always keep your eyes on official documentation.