2017 © Pedro Peláez
 

library laravel-socialite

Social OAuth authentication for Laravel 5.

image

overtrue/laravel-socialite

Social OAuth authentication for Laravel 5.

  • Friday, March 30, 2018
  • by overtrue
  • Repository
  • 3 Watchers
  • 174 Stars
  • 12,648 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 20 Forks
  • 5 Open issues
  • 7 Versions
  • 26 % Grown

The README.md

Laravel Socialite

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

Sponsor me, (*2)

Installation

$ composer require "overtrue/laravel-socialite"

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

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:, (*4)

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

About more usage, please refer to overtrue/socialite., (*5)

:heart: Sponsor me

Sponsor me, (*6)

如果你喜欢我的项目并想支持它,点击这里 :heart:, (*7)

Project supported by JetBrains

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

, (*9)

PHP 扩展包开发

想知道如何从零开始构建 PHP 扩展包?, (*10)

请关注我的实战课程,我会在此课程中分享一些扩展开发经验 —— 《PHP 扩展包实战教程 - 从入门到发布》, (*11)

License

MIT, (*12)

The Versions

30/03 2018

dev-master

9999999-dev

Social OAuth authentication for Laravel 5.

  Sources   Download

MIT

The Requires

 

by Avatar overtrue

14/12 2017

2.0.0

2.0.0.0

Social OAuth authentication for Laravel 5.

  Sources   Download

MIT

The Requires

 

by Avatar overtrue

03/07 2017

1.1.0

1.1.0.0

Social OAuth authentication for Laravel 5.

  Sources   Download

MIT

The Requires

 

by Avatar overtrue

03/07 2017

1.0.3

1.0.3.0

Social OAuth authentication for Laravel 5.

  Sources   Download

MIT

The Requires

 

by Avatar overtrue

29/01 2017

1.0.2

1.0.2.0

Social OAuth authentication for Laravel 5.

  Sources   Download

MIT

The Requires

 

by Avatar overtrue

10/03 2016

1.0.1

1.0.1.0

Social OAuth authentication for Laravel 5.

  Sources   Download

MIT

The Requires

 

by Avatar overtrue

13/12 2015

1.0.0

1.0.0.0

Social OAuth authentication for Laravel 5.

  Sources   Download

MIT

The Requires

 

by Avatar overtrue