PHP code example of lramos1994 / wp-api-jwt-auth

1. Go to this page and download the library: Download lramos1994/wp-api-jwt-auth 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/ */

    

lramos1994 / wp-api-jwt-auth example snippets


define('JWT_AUTH_SECRET_KEY', 'your-top-secrect-key');

define('JWT_AUTH_CORS_ENABLE', true);


$token = array(
    'iss' => get_bloginfo('url'),
    'iat' => $issuedAt,
    'nbf' => $notBefore,
    'exp' => $expire,
    'data' => array(
        'user' => array(
            'id' => $user->data->ID,
        )
    )
);


$data = array(
    'token' => $token,
    'user_email' => $user->data->user_email,
    'user_nicename' => $user->data->user_nicename,
    'user_display_name' => $user->data->display_name,
);