Am almost done with an app am building with codeigniter, and i want to create a REST api which will allow the mobile version of the site and maybe in the future native mobile apps communicate with the database via a REST api.
Am using Phil Sturgeon REST Controller library, for now am able to create api keys for my users which are stored on the db.The API is primarily for creating a backend, and is to have closed access for certain parts the main for the main.
My question is:
Is possible to authenticate users with api and still use the api keys
0
votes
1 Answers
0
votes
If you're creating a separate API Key for each user, then you can just add in some logic in your API controllers to authenticate and give them access to certain methods.
Otherwise, you can create some API methods that would authenticate the user - pass back a "request token" and then use that for subsequent requests. Then you would give access to certain methods based on that request token.
The gist is that you need some identifying information. If it is an API Key, then that works. If not, you'll need to create that identifying information. (for this example, that would be the "request token".