LaravelPackages.net
Acme Inc.
Toggle sidebar
rinordreshaj/apple-sign-in

Integrate apple sign in easily

750
23
0.3.1
About rinordreshaj/apple-sign-in

rinordreshaj/apple-sign-in is a Laravel package for integrate apple sign in easily. It currently has 23 GitHub stars and 750 downloads on Packagist (latest version 0.3.1). Install it with composer require rinordreshaj/apple-sign-in. Discover more Laravel packages by rinordreshaj or browse all Laravel packages to compare alternatives.

Last updated

Laravel Sign in with Apple

Integrate sign in with apple easily

This package provides an easy sign in with apple authentication model based on the apple specification

Installation

Require this package with composer using the following command:

composer require rinordreshaj/apple-sign-in

provide package name & service name generated from on the itunes connect on the .env file

APPLE_SIGN_IN_PACKAGE_NAME=your.package.name
APPLE_SIGN_IN_SERVICE_NAME=your.service.name

Usage

<?php

namespace App\Http\Controllers\API\Auth;

use Rinordreshaj\AppleSignIn\AppleSignIn;

class AppleSignInController extends Controller
{
    public function login()
    {
        if(AppleSignIn::verify_signature($request->jwt_token))
        {
            // Authentication verified
            $claims = AppleSignIn::get_token_claims($request->access_token);

            $user = User::where([
                    'apple_identifier' => $claims->sub
                ])
                ->orWhere(["email" => $claims->email])
                ->first();

            if(!$user)
            {
             // ADD user on database if it doesn't exists
                $user = User::create([
                    "apple_identifier" => $claims->sub,
                    "email"            => $claims->email,
                    "first_name"       => $request->first_name,
                    "last_name"        => $request->last_name,
                    "register_source"  => "apple"
                ]);
            // You can return the authenticated user object 
        }
    }
}

License

The Laravel Sign in with Apple is open-sourced software licensed under the MIT license

Star History Chart