I am using jwt-simple to create an api key. Basically, it executes encode(secret+data) and sends it with the request. I know that the server will be decode(encode(secret+data)) and checks if it is a valid request. Example code found in jwt-simple documentation :
var jwt = require('jwt-simple'); var payload = { foo: 'bar' }; var secret = 'xxx';
My questions:
- Wouldn't anyone be able to access the API if they know the token generated by
encode(data+key) ? So should I use HTTPS over HTTP? - I think I need to keep the secret of each user on the server, as it will be needed for decoding. Where should I keep it, if I'm wrong?
- How to send multiple API requests? Is there a better way besides sending an API key for each request?
Thanks in advance.
source share