I have a node.js backend for an ios app that will provide json data to the app. I want to handle client authentication for each app. The users do not need to create an account. I only want to identify the client apps when providing data and save some data for each client on the node server.
- How do I handle identifying each app on the server?
- If I need to create an API key, how do I handle that?
- If there is a way to authenticate the app when the app first accesses the API, how can I create a unique identifier for the app?
- Last, what do I need to know before I deploy the node server? Can I get away by just pointing a domain to my router, opening a port and serving the api from there or is it a must to have a web server setup to handle that?
Thank you
I have a node.js backend for an ios app that will provide json data to the app. I want to handle client authentication for each app. The users do not need to create an account. I only want to identify the client apps when providing data and save some data for each client on the node server.
- How do I handle identifying each app on the server?
- If I need to create an API key, how do I handle that?
- If there is a way to authenticate the app when the app first accesses the API, how can I create a unique identifier for the app?
- Last, what do I need to know before I deploy the node server? Can I get away by just pointing a domain to my router, opening a port and serving the api from there or is it a must to have a web server setup to handle that?
Thank you
Share Improve this question asked Apr 29, 2017 at 0:12 tewtew 2814 silver badges14 bronze badges 1- Have you done any research on your own? What have you tried? What has or hasn't worked? – Hydrothermal Commented Apr 29, 2017 at 2:39
1 Answer
Reset to default 3You can basically find a lot of blogs posts to get best practices to follow when designing an api. But here is an over all idea
You can create a client key and send it on every api request or add as part of url
Example: api.example./v1/users?client=android&version=1.1
Use Middileware. You can either name as to your convenience or have a database to store key value to manage your clients. Example:
Create a Middleware which does the handling of authentication and API key checker before you forward it to the routes.
android => 0, ios => 1, web => 2
url: api.example./v1/users?client=0&version=1.1
There are many ways to create api keys. Here are some of them
UUID - https://www.npmjs./package/uuid
Json web token - https://github./auth0/node-jsonwebtoken
Oauth - https://github./ciaranj/node-oauth
Again, You have a lot of online posts explaining best practices to follow in production. If express.js, You can find best practices to follow here Express Production
This is just an overview. I request you to do a lot of research online and ask a relative more concrete problems you face towards your learning.