CodeIgniter 3 Promise Implementation

My CI application makes an API call to a third-party Rest API server, which will be used by the front-end. At first, the application for the external interface will get into my CI application, which, in turn, will fall into the third party LogInAPI (the session is valid for 15 minutes), and after entering the system we need to press subsequent API calls, passing the key ( LogInAPI response) to heading. So basically I need to click LogInAPI every 15 minutes. I am trying angular to promise a curious approach in my Codeigniter application do not know how to achieve it? what is the best way to do this to prevent the front end from getting empty or an expired session?

+5
source share
1 answer

You do not need to update this login. Create a timestamp when you receive a login from a third-party API. Then pass it to the end for each request.

On the back of each call, from the front end check timestamp, if it has expired, do not make regular API calls, but first get a new login, then make the requested calls.

As an answer to every external call, also return login information, so that before updating the user receives new credentials.

If the credentials are wide applications, then the front end shouldn't know about them at all. Just save the credentials in some kind of store (SQL DB, store of key values, etc.) And, if necessary, perform an automatic renewal.

+1
source

Source: https://habr.com/ru/post/1271467/


All Articles