A socialite driver for Passport

0.2.0 2019-12-14 23:01 UTC

This package is auto-updated.

Last update: 2020-03-14 23:41:10 UTC


Packagist License Latest Stable Version Build Status

A Laravel Socialite driver for authenticating with Laravel Passport OAuth servers.


This package can be installed using Composer. The Socialite package will also be installed if it is not already installed.

composer require matt-allan/passport-socialite


Before using this driver, you will need to add credentials for the Passport server. These credentials should be placed in your config/services.php configuration file, and should use the key passport. For example:

'passport' => [
    'client_id' => env('PASSPORT_CLIENT_ID'),
    'client_secret' => env('PASSPORT_CLIENT_SECRET'),
    'url' => env('PASSPORT_URL'),
    'redirect' => env('PASSPORT_REDIRECT'),


The Passport driver works identically to the other Socialite drivers. All of the methods mentioned in the official documentation are available.

You can access the passport driver using the Socialite facade:


namespace App\Http\Controllers\Auth;

use Socialite;

class LoginController extends Controller
     * Redirect the user to the Passport server's authentication page.
     * @return \Illuminate\Http\Response
    public function redirectToProvider()
        return Socialite::driver('passport')->redirect();

     * Obtain the user information from the Passport server.
     * @return \Illuminate\Http\Response
    public function handleProviderCallback()
        $user = Socialite::driver('passport')->user();

        // $user->token;

The current user's details will be retrieved from the default api/user route.

In addition to the standard Socialite methods a refresh method is available to easily refresh expired tokens. The refresh method accepts a refresh token and returns an updated User with new access and refresh tokens if the token is refreshed successfully.

$user = Socialite::driver('passport')->refresh($refreshToken);

Change log

Please see CHANGELOG for more information on what has changed recently.


$ composer test


Please see CONTRIBUTING for details.



The MIT License (MIT). Please see License File for more information.