1. Go to this page and download the library: Download overtrue/laravel-socialite library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
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();
// ...
}
}