How to include token in API rest |
Hello!! I am trying to create an API rest, I am simply fetching data from a Database via GET.
It works perfectly but, I want to generate tokens so that it has security. I have searched but still can not find something that can serve me. I was recommended to use https://jwt.io but I really do not understand it, if someone has a document or guide that can send me, I will appreciate it.
How complex/complicated do you want/need to be? Your question is rather generic to be answered easily.
Here is what i do. I only need simple security as in my case its public data that is returned. But I want to stop just anybody using this API. I create a client_secret that I send to everybody that will be using the API. They need to send this client_secret with each request. The API checks if that client_secret exist in my user table before returning any data. This way I can add or remove clients_secrets easily and make sure only people that I want to can access the data. If you tell us a bit more about your setup and what you try to archive and avoid we might be able to help you a little better.
On the package it said needs Windows 7 or better. So I installed Linux.
Method to create UUID's
PHP Code: /** Create a helper and add the code above. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
07-07-2017, 12:41 AM
(This post was last modified: 07-08-2017, 04:31 AM by arisroyo. Edit Reason: Change constant for generated key )
Here my example
1. I create Libraries Jsonwebtokens.php and put it on /application/libraries 2. Download https://github.com/firebase/php-jwt and put on /application/third_party/firebase-jwt 3. Here how I used it Example: PHP Code: $this->load->library('jsonwebtokens'); Jsonwebtokens.php PHP Code: <?php
There are those who tell lies with meaning behind them and those meaning less lies!
|
Welcome Guest, Not a member yet? Register Sign In |