PHP

laravel-socialite

Social OAuth Authentication for Laravel 5. drivers: facebook, github, google, linkedin, weibo, qq, wechat and douban

O

overtrue

Dernière activité 24 mai 2026
overtrue/laravel-socialite

344

étoiles

46

forks

0

issues ouvertes

facebookgooglelaravel-socialitelinkedinsocial-loginsocialitewechatweibo

Ce README est souvent en anglais.

Laravel Socialite

Laravel Octane Ready Status GitHub release (latest SemVer) GitHub License Packagist Downloads

Sponsor me

Installation

$ composer require "overtrue/laravel-socialite"

if you have been installed the overtrue/socialite package, please remove it from composer.json before this command.

Configuration

  1. You will also need to add credentials for the OAuth services your application utilizes. These credentials should be placed in your config/socialite.php or config/services.php configuration file, and should use the key facebook, twitter, linkedin, google, github or bitbucket, depending on the providers your application requires. For example:
 <?php

 return [
     //...
     'github' => [
         'client_id'     => 'your-app-id',
         'client_secret' => 'your-app-secret',
         'redirect'      => 'http://localhost/socialite/callback.php',
     ],
     //...
 ];

Usage

<?php

namespace App\Http\Controllers;

use Socialite;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;

class AuthController extends Controller
{
    /**
     * Redirect the user to the GitHub authentication page.
     */
    public function redirectToProvider()
    {
        return redirect()->to(Socialite::create('github')->redirect());
    }

    /**
     * Obtain the user information from GitHub.
     */
    public function handleProviderCallback(Request $request)
    {
        $user = Socialite::create('github')->userFromCode($request->query('code'));

        // $user->getId();
        // $user->getNickname();
        // ...
    }
}

And register routes:

Route::get('/oauth/github', 'AuthController@redirectToProvider');
Route::get('/oauth/github/callback', 'AuthController@handleProviderCallback');

About more usage, please refer to overtrue/socialite.

❤️ Sponsor me

Sponsor me

如果你喜欢我的项目并想支持它,点击这里 ❤️

Project supported by JetBrains

Many thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects.

License

MIT

Projets similaires

Socialite is an OAuth2 Authentication tool. It is inspired by laravel/socialite, you can easily use it without Laravel.

PHPalipaybaidudingtalk
Oovertrue
1,4 k étoiles244

Laravel wrapper around OAuth 1 & OAuth 2 libraries.

PHPlaraveloauth
Llaravel
5,7 k étoiles960

Open source social sign on PHP Library. HybridAuth goal is to act as an abstract api between your application and various social apis and identities providers such as Facebook, Twitter and Google.

PHPfacebookgooglehybridauth
Hhybridauth
3,4 k étoiles1,1 k