1. Go to this page and download the library: Download hamedov/passport-multiauth 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/ */
protected function getUserEntityByRequestParams(Model $model, $request_params,
$guard, $grantType, ClientEntityInterface $clientEntity)
{
// Do your logic to authenticate the user.
// Return false or void if authentication fails.
// This will throw OAuthServerException.
$facebook_access_token = $request_params['facebook_access_token'];
// Contact facebook server to make sure the token is valid and get the corresponding user profile.
$profile = file_get_contents('https://graph.facebook.com/me?fields=name,email&access_token='.$facebook_access_token);
$profile = (array) json_decode($profile);
if ( ! isset($profile['email']))
{
// We cannot identify the user without his email address
return;
}
// Retrieve user or any authenticatable model by email or create new one.
$user = $model->firstOrCreate(['email' => $profile['email']], ['name' => $profile['name']]);
return new User($user->getAuthIdentifier());
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.