How to verify JWT Token in CodeIgniter 3.x for every request from Client
first create a helper from code https://github.com/rmcdaniel/angular-codeigniter-seed/blob/master/api/application/helpers/jwt_helper.php
then load or auto load this helper.
This will give you the token
helper_name::encode(data, secure_key)
To verify you need to use
helper_name::decode(token,secure_key,true)
it will give you data which you have encoded or it will give you false if token is not valid.
Important Update:
I updated the repository to CodeIgniter 4. Developers who want to use CodeIgniter 3, use following command:
git checkout CI3
Original Answer:
I have created a repository which contains this code including helper class.
Since this is a sample code, I am not expecting any username
or password
.
GET auth token
URL: http://host/CodeIgniter-JWT-Sample/auth/tokenMethod: GET
Check decoded token
URL: http://host/CodeIgniter-JWT-Sample/auth/tokenMethod: POSTHeader Key: AuthorizationValue: Auth token generated in GET call