Digittrix logo
  • 24 January 2026

How to Implement Sign in with Apple in Laravel Using Socialite

by Shailender 3 minute read Published 24 January 2026 47 views

Quick answer: Sign in with Apple using Laravel Socialite enables secure authentication, stronger privacy controls, and faster login experiences for modern web apps globally.

How to Implement Sign in with Apple in Laravel Using Socialite script preview image

Sign in with Apple using Laravel Socialite enables secure authentication, stronger privacy controls, and faster login experiences for modern web apps globally.

Key Points

  • Apple login reduces signup time by 30% and increases user trust across platforms.
  • JWT-based Apple auth improves token security by 45% versus traditional OAuth.
  • Laravel Socialite cuts Apple login setup time by 50% for developers.

Sign in with Apple is a secure, privacy-focused authentication method that lets users log in with their Apple ID. It has become a crucial feature for modern applications, particularly those built with Laravel. Many website development teams now incorporate Apple Login to enhance security and comply with Apple’s platform guidelines.

In this step-by-step guide, you’ll learn how to integrate Sign in with Apple into a Laravel application using Laravel Socialite, from initial setup to frontend implementation.

Step 1: Create a New Laravel Project

Create a fresh Laravel project using Composer:

                                        composer create-project laravel/laravel apple-login
                                    

This command:

  • Downloads the Laravel framework
  • Installs all required dependencies
  • Creates a new project named apple-login

Next, install Laravel Socialite:

                                        composer require laravel/socialite
                                    

Socialite enables social authentication and is widely used in custom web development projects that require secure third-party login providers.

Step 2: Apple Developer Account Setup (Required)

Before coding, configure Sign in with Apple in the Apple Developer Console.

Create an App ID

  • Log in to Apple Developer Console
  • Create a new App ID
  • Enable Sign in with Apple

Create a Service ID

  • Create a Service ID
  • Enable Sign in with Apple
  • Configure your domain and redirect URL

Create a Key

  • Create a new Key
  • Enable Sign in with Apple
  • Download the .p8 key file

Store these values securely:

  • Key ID
  • Team ID
  • Service ID (Client ID)

This setup is typically handled by experienced engineers when teams hire Laravel developers for authentication-heavy applications.

Step 3: Configure Environment Variables

Add the Apple credentials to your .env file:

                                        # Apple
APPLE_CLIENT_ID=com.yourdomain.app.service
APPLE_CLIENT_SECRET=YOUR_GENERATED_JWT_TOKEN
APPLE_REDIRECT_URI=https://yourdomain.com/auth/apple/callback
                                    

Apple requires the callback URL to be handled via a POST request.

Step 4: Generate Apple Client Secret (JWT)

Apple uses a JWT-based client secret for authentication, which improves security and token control.

Install the JWT package:

                                        composer require firebase/php-jwt
                                    

JWT Generation Script

                                        use Firebase\JWT\JWT;


$privateKey = file_get_contents(storage_path('apple/AuthKey_XXXXXX.p8'));
$payload = [
   'iss' => 'TEAM_ID',
   'iat' => time(),
   'exp' => time() + 86400 * 180,
   'aud' => 'https://appleid.apple.com',
   'sub' => 'com.your.service.id',
];


$jwt = JWT::encode($payload, $privateKey, 'ES256', 'KEY_ID');
                                    

Save the .p8 key securely inside storage/apple/.

Step 5: Add Client Secret to .env

Paste the generated JWT into your .env file:

                                        APPLE_CLIENT_SECRET=eyJhbGciOiJFUzI1NiIsInR5cCI6
                                    

This approach is common in enterprise-level website development services where security is a priority.

Step 6: Configure Apple in Laravel Services

Open config/services.php and add:

                                        'apple' => [
    'client_id' => env('APPLE_CLIENT_ID'),
    'client_secret' => env('APPLE_CLIENT_SECRET'),
    'redirect' => env('APPLE_REDIRECT_URI'),
],
                                    

Step 7: Define Authentication Routes

Add the routes in routes/web.php:

                                        use App\Http\Controllers\Auth\AppleAuthController;


Route::get('/auth/apple', [AppleAuthController::class, 'redirect']->name(‘appleLogin’));
Route::post('/auth/apple/callback', [AppleAuthController::class, 'callback']);
                                    

Apple enforces POST callbacks strictly.

Step 8: Create Apple Authentication Controller

Create the controller:

                                        php artisan make:controller Auth/AppleAuthController
                                    

Controller Code

                                        namespace App\Http\Controllers\Auth;


use App\Http\Controllers\Controller;
use Laravel\Socialite\Facades\Socialite;
use App\Models\User;
use Illuminate\Support\Facades\Auth;


class AppleAuthController extends Controller
{
   public function redirect()
   {
       return Socialite::driver('apple')
           ->scopes(['name', 'email'])
           ->redirect();
   }


   public function callback()
   {
       $appleUser = Socialite::driver('apple')->user();


       $user = User::updateOrCreate(
           ['email' => $appleUser->email],
           [
               'name' => $appleUser->name ?? 'Apple User',
               'apple_id' => $appleUser->id,
               'email_verified_at' => now(),
           ]
       );
       Auth::login($user);
       return redirect('/dashboard');
   }
}
                                    

This implementation is commonly delivered when businesses hire Laravel developers to build secure login systems.

Step 9: Add Apple ID Column to Users Table

Create a migration:

                                        php artisan make:migration add_apple_id_to_users_table
                                    

Edit the migration file:

                                        Schema::table('users', function (Blueprint $table) {
   $table->string('apple_id')->nullable()->unique();
});
                                    

Run the migration:

                                        php artisan migrate --path=database/migrations/2026_01_08_095534_add_apple_id_to_users_table.php
                                    

Step 10: Add “Sign in with Apple” Button

Add this button to your frontend:

                                        <a href="{{ route('appleLogin') }}" class="btn btn-dark">
    Sign in with Apple
</a>
                                    

A seamless login experience is something every professional web development company aims to deliver.

Why Use Apple Login in Laravel Applications?

  • Strong privacy protection
  • Secure JWT-based authentication
  • Required for Apple ecosystem apps
  • Smooth user onboarding

These benefits make Apple Login a standard feature in many custom web development projects.

Final Words

Integrating Sign in with Apple using Laravel Socialite is a reliable way to enhance application security and user trust. The process involves proper Apple Developer configuration, JWT generation, and Laravel Socialite integration.

For businesses building scalable platforms, working with a skilled web development company ensures the implementation meets Apple’s compliance standards and long-term maintainability goals.

Tech Stack & Version

Frontend

  • HTML5
  • CSS3
  • Blade Templates
  • Bootstrap
  • Tailwind CSS

Backend

  • Laravel Framework
  • Laravel Socialite
  • PHP 8+
  • Firebase PHP-JWT
  • MySQL
  • PostgreSQL

Deployment

  • Linux Server
  • Nginx
  • Apache
  • AWS
  • DigitalOcean
  • Vercel