Socialite laravel 8 code example
Example 1: socialite laravel 7
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Laravel\Socialite\Facades\Socialite;
class LoginController extends Controller
{
public function redirectToProvider()
{
return Socialite::driver('github')->redirect();
}
public function handleProviderCallback()
{
$user = Socialite::driver('github')->user();
}
}
Example 2: laravel facebook socialite
composer require laravel/socialite
Example 3: socialite laravel 7
$user = Socialite::driver('github')->user();
$token = $user->token;
$refreshToken = $user->refreshToken;
$expiresIn = $user->expiresIn;
$token = $user->token;
$tokenSecret = $user->tokenSecret;
$user->getId();
$user->getNickname();
$user->getName();
$user->getEmail();
$user->getAvatar();
Example 4: socialite laravel 7
$user = Socialite::driver('twitter')->userFromTokenAndSecret($token, $secret);
Example 5: socialite laravel 7
return Socialite::driver('google')
->with(['hd' => 'example.com'])
->redirect();
Example 6: socialite laravel 7
$user = Socialite::driver('github')->userFromToken($token);