PHP code example of mosip / php-auth-sdk

1. Go to this page and download the library: Download mosip/php-auth-sdk 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/ */

    

mosip / php-auth-sdk example snippets




$configDir = dirname(__FILE__);

return [
    'mosip_auth' => [
        'timestamp_format' => 'Y-m-d\TH:i:s',
        'ida_auth_version' => '1.0',
        'ida_auth_request_demo_id' => 'mosip.identity.auth',
        'ida_auth_request_kyc_id' => 'mosip.identity.kyc',
        'ida_auth_request_otp_id' => 'mosip.identity.otp',
        'ida_auth_env' => 'Staging',
        'authorization_header_constant' => 'Authorization',
        'partner_apikey' => 'YOUR_API_KEY',
        'partner_misp_lk' => 'YOUR_MISP_LK',
        'partner_id' => 'YOUR_PARTNER_ID',
    ],
    'mosip_auth_server' => [
        'ida_auth_domain_uri' => 'https://api-internal.YOUR_DOMAIN',
        'ida_auth_url' => 'https://api-internal.YOUR_DOMAIN/idauthentication/v1',
    ],
    'crypto_encrypt' => [
        'symmetric_key_size' => 256,
        'symmetric_nonce_size' => 128,
        'symmetric_gcm_tag_size' => 128,
        'encrypt_cert_path' => $configDir . '/keys/ida.pem',
        'decrypt_p12_file_path' => $configDir . '/keys/pa.p12',
        'decrypt_p12_file_password' => 'YOUR_P12_PASSWORD',
    ],
    'crypto_signature' => [
        'algorithm' => 'RS256',
        'sign_p12_file_path' => $configDir . '/keys/pa.p12',
        'sign_p12_file_password' => 'YOUR_P12_PASSWORD',
    ],
    'logging' => [
        'log_file_path' => $configDir . '/authenticator.log',
        'log_format' => '[%s] %s - %s - %s',
        'loglevel' => 'DEBUG',
    ],
];



osipAuth\MOSIPAuthenticator;
use MosipAuth\Models\DemographicsModel;
use MosipAuth\Models\IdentityInfo;

$config =  [new IdentityInfo('eng', 'John Doe')];
$demographicsData->dob = '1990/01/01';
$demographicsData->gender = [new IdentityInfo('eng', 'male')];

$response = $authenticator->kyc(
    '9502435413',
    'UIN',
    $demographicsData,
    '',
    [],
    true
);

if ($response->getStatusCode() === 200) {
    $responseBody = json_decode($response->getBody()->getContents(), true);
    $decryptedResponse = $authenticator->decryptResponse($responseBody);
    print_r($decryptedResponse);
}

$response = $authenticator->genotp(
    '9502435413',
    'UIN',
    '',
    true,  // email
    true   // phone
);

$responseBody = json_decode($response->getBody()->getContents(), true);
$transactionId = $responseBody['transactionID'];

$response = $authenticator->kyc(
    '9502435413',
    'UIN',
    $demographicsData,
    '123456',  // OTP value
    [],
    true,
    $transactionId  // Transaction ID from OTP generation
);
bash
composer 
bash
git clone https://github.com/abdulbathish/php-auth-sdk.git
cd php-auth-sdk