DEV Community

Nasrul Hazim Bin Mohamad
Nasrul Hazim Bin Mohamad

Posted on

Socialite ReCall

I’m excited to share my latest open‑source package: Socialite ReCall 🎉

If you’ve ever found yourself duplicating redirect and callback logic for multiple Socialite providers (Google, GitHub, Facebook, etc.), this package is built for you.

✨ What Socialite ReCall Does

  • Handles redirects, callbacks, and logouts for any Socialite provider.
  • Keeps your controllers clean — no more boilerplate OAuth logic.
  • Easy to configure, provider‑agnostic, and ready for quick integration.

🚀 Usage

1. Install & Configure

composer require cleaniquecoders/socialite-recall
php artisan socialite-recall:install
Enter fullscreen mode Exit fullscreen mode

This will publish a config file:
config/socialite-recall.php

Update it to match your needs:

return [
    'providers' => ['google', 'github', 'facebook'],

    'redirect_after_login' => '/dashboard',

    'redirect_after_logout' => '/',
];
Enter fullscreen mode Exit fullscreen mode

2. Setup Socialite Providers

In your .env file:

GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
GOOGLE_REDIRECT_URI=${APP_URL}/auth/google/callback

GITHUB_CLIENT_ID=your-github-client-id
GITHUB_CLIENT_SECRET=your-github-client-secret
GITHUB_REDIRECT_URI=${APP_URL}/auth/github/callback
Enter fullscreen mode Exit fullscreen mode

In config/services.php:

'google' => [
    'client_id' => env('GOOGLE_CLIENT_ID'),
    'client_secret' => env('GOOGLE_CLIENT_SECRET'),
    'redirect' => env('GOOGLE_REDIRECT_URI'),
],

'github' => [
    'client_id' => env('GITHUB_CLIENT_ID'),
    'client_secret' => env('GITHUB_CLIENT_SECRET'),
    'redirect' => env('GITHUB_REDIRECT_URI'),
],
Enter fullscreen mode Exit fullscreen mode

3. Use the Built‑In Routes

Your app automatically gets:

Route Purpose
GET /auth/{provider}/redirect Redirect to the provider
GET /auth/{provider}/callback Handle provider callback
POST /auth/logout Logout the current user

Replace {provider} with any in your config (google, github, facebook, etc.).


4. Example Blade Buttons

<!-- Google Login -->
<a href="{{ route('socialite.redirect', ['provider' => 'google']) }}">
    <button type="button">Login with Google</button>
</a>

<!-- GitHub Login -->
<a href="{{ route('socialite.redirect', ['provider' => 'github']) }}">
    <button type="button">Login with GitHub</button>
</a>

<!-- Logout -->
<form action="{{ route('socialite.logout') }}" method="POST">
    @csrf
    <button type="submit">Logout</button>
</form>
Enter fullscreen mode Exit fullscreen mode

5. After Login

  • Redirect + callback handled automatically.
  • User record created or updated (provider + provider_id).
  • User logged in automatically.
  • Redirected to:
'redirect_after_login' => '/dashboard',
Enter fullscreen mode Exit fullscreen mode

⚡ Done! You now have a unified Socialite login flow with minimal setup.

Top comments (0)