How to include token in API rest - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: How to include token in API rest (/showthread.php?tid=68386) |
How to include token in API rest - avasquez - 07-04-2017 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. RE: How to include token in API rest - rtenny - 07-05-2017 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. RE: How to include token in API rest - InsiteFX - 07-05-2017 Method to create UUID's PHP Code: /** Create a helper and add the code above. RE: How to include token in API rest - arisroyo - 07-07-2017 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 |