1. Go to this page and download the library: Download onetechasia/cognito 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/ */
onetechasia / cognito example snippets
'guards' => [
'cognito-token' => [
'driver' => 'cognito-token', // This line is important for using AWS Cognito as API Driver
'provider' => 'users',
],
],
use Onetech\Cognito\Auth\RegistersUsers;
use Onetech\Cognito\Auth\AuthenticatesUsers;
use Onetech\Cognito\Auth\RefreshToken;
class UserController
{
use CognitoAuthenticatesUsers, RegistersUsers, RefreshToken;
}
//Registering user
$bool = $this->createCognitoUser($request);
//return boolean
//Login user
$check = $this->attemptLogin($request);
//Response using AccessToken for call API
//Response using RefreshToken to fetch new AccessToken
//Response using IdToken to get user information
//Fetch new AccessToken and IdToken
$response = $this->refreshCoginitoToken($request);
//Same API login