Download the PHP package lamy/laravel-sign-in-apple without Composer
On this page you can find all versions of the php package lamy/laravel-sign-in-apple. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download lamy/laravel-sign-in-apple
More information about lamy/laravel-sign-in-apple
Files in lamy/laravel-sign-in-apple
Package laravel-sign-in-apple
Short Description Laravel package to authenticate users using Sign in with Apple
License MIT
Homepage https://github.com/Edouard-LAMY/laravel-sign-in-apple
Informations about the package laravel-sign-in-apple
Laravel Sign In with Apple
[]
Laravel Sign In with Apple is a simple package that makes it easier to implement Apple Sign In using Laravel 12 and Socialite.
It handles Apple-specific configurations, token generation, and user data parsing to provide a smooth authentication flow.
🚀 Features
- Easy integration with Laravel and Socialite
- Automatic
client_secretgeneration for Apple - Secure decoding of Apple tokens
- Simple
.envconfiguration - Fully customizable authentication logic
📦 Installation
You can install the package via composer:
You can add the configuration apple in config/services.php:
We also recommend using laravel/socialite and socialiteproviders/apple to automatically manage user resolution and persistence:
Add Event to AppServiceProvider.php in function boot():
⚙️ Apple Developer Configuration
1. Create an App ID
- Go to the Apple Developer Console
- Create a new App ID: Create a Bundle ID
- Description:
example.com App ID - Bundle ID (explicit):
com.example.id - Enable: ✅ Sign In with Apple
- Description:
- Retrieve your Team ID (e.g.
123AZ987ZA) - Add it to your
.envfile:
2. Create a Service ID
- Go to Create a Service ID
- Click ➕ Add:
- Description:
example.com Service ID - Identifier:
com.example.service - Enable: ✅ Sign In with Apple
- Description:
- Click Configure under "Sign In with Apple":
- Primary App ID: select the App ID created in step 1
- Web Domain:
example.com(your website domain) - Return URL:
https://example.com/auth/callback(your Laravel route)
- Click Save
- Go back and click Edit to confirm the config is saved
- Add this to your
.env:
3. Create a Sign In with Apple Key
- Go to Create a Key in the Apple Developer Console
- Click + Add
- Enter a Key Name (e.g., Sign In with Apple Key)
- ✅ Enable Sign In with Apple
- Select the Primary App ID created in step 1
- Click Continue, then Register
- Click Download to get the
.p8key file (⚠️ this download is only available once) - Rename the downloaded file from
AuthKey_12345ABCD.p8tokey.pemby running:
Place the key.pem file at the root of your Laravel project (same level as your .env)
Add the following to your .env file:
4. Final .env keys overview
You should have these keys in your .env file:
The APPLE_CLIENT_SECRET will be generated later.
5. Generate the Client Secret Token
To generate the first client secret token, run the following in artisan tinker:
Then inside tinker:
Copy the generated token and set it in your .env:
6. Routing
Add the following routes to your routes/auth.php: ⚠️ Specify the callback name as: apple-callback
7. Controller Example
Here is an example controller to handle the Apple Sign In flow:
🔐 Token Generation and Apple Authentication
generateToken()
The static method generateToken() does not require any parameters.
If you've run the installation command:
and properly set the following environment variables: APPLE_CLIENT_ID APPLE_TEAM_ID APPLE_KEY_ID
Then this method will return a string, which is your APPLE_CLIENT_SECRET — you can paste it into your .env file. ℹ️ This token is valid for 6 months. After that, you’ll need to generate a new one and update APPLE_CLIENT_SECRET again.
🔐 Decode Apple Token Authentication
decodeAppleToken(Request $request)
The static method decodeAppleToken() expects an instance of Illuminate\Http\Request as a parameter, to handle the callback from Apple.
It will: Extract the authorization code from $request->input('code') Exchange the authorization code for an access token, Verify the Apple ID token’s signature, Extract user data (ID, email, name) and return a structured object for use in your app.
✅ Returned object structure The returned object provides the following methods and properties:
⚠️ Errors are silently encapsulated in the returned object using:
You can choose to handle these errors manually.
🔒 Security notes The Apple ID token (JWT) is validated against Apple’s public key.
The method uses: firebase/php-jwt phpseclib/phpseclib
to handle cryptographic operations and ensure secure authentication.
⚠️ Handling Missing Name and Email
If a user doesn’t provide name and email during the Apple Sign In, they can: On their iPhone, go to Settings Tap on their Avatar or Name Tap Sign In with Apple Remove the app that was previously authorized
Retry the login flow; Apple will prompt for name and email only once
For more info, see: StackOverflow - Laravel Socialite Apple Sign In no user info https://stackoverflow.com/questions/78101351/laravel-socialite-apple-sign-in-no-user-info/78294921
Credits - Edouard LAMY
All versions of laravel-sign-in-apple with dependencies
firebase/php-jwt Version ^6.11
guzzlehttp/guzzle Version ^7.10
illuminate/contracts Version ^11.0||^12.0
phpseclib/phpseclib Version ^3.0
spatie/laravel-package-tools Version ^1.16