PHP code example of matt-allan / passport-socialite
1. Go to this page and download the library: Download matt-allan/passport-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\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;
}
}