1. Go to this page and download the library: Download appkita/phpauth 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/ */
$configApi = [
'google' = [
'clientID' => 'your client id',
'clientSecret' => 'secret client',
'redirectUri' => 'redirect url',
];
'facebook' = [
'clientID' => 'your client id',
'clientSecret' => 'secret client',
'redirectUri' => 'redirect url',
];
]
//identifikasi Facebook Library
$FB = new \Appkita\PHPAuth\Type\Facebooklogin($configApi);
//identifikas google library
$GOOGLE = new \Appkita\PHPAuth\Type\GoogleLogin($this->configApi);
//get FB login url
function loginFB() {
header('location:'. $FB->urlLogin());
}
//get Google Login url
function loginGoogle() {
header('location:'. $GOOGLE->urlLogin());
}
//url callback fb login to verify token
function verify_fb() {
return $FB->decode(function($user, $args, $error) {
die(json_encode($user));
});
}
//url callback fb Google to verify token
function verify_fb() {
return $FB->decode(function($user, $args, $error) {
die(json_encode($user));
}, []);
}
$config = [
'key_header'=>'X-API-KEY', //Delete if you not use API KEY
//jwt Configuration
'key'=>'key_JWT',
'data'=>'username',
'timeout'=>3600,
'iss'=>'mydomain.com',
'aud'=>'mydomain.com',
'basic_auth'=>[
'username_key'=>'email',
'password_key'=>'password'
];
];
$auth = new Appkita\PHPAuth\Authentication($config);
//or
use Appkita\PHPAuth;
$auth = new Authentication($config);
//or configuration default
$auth = new Authentication();