Authenticate REST API services in java

815 Views Asked by At

I have created a restful service using jersey in java.The API tested with HTTP client as well. its working fine.I need to secure my API with username and password. anyone can help me out to do this.. Thanks in advance.

1

There are 1 best solutions below

1
On

No need to send username and password every time. On just first login api send username and password to server and then server returns on key which is stored as your session key in database at server side.

You need to send this key on every api call in header, so server side they authenticate user first on each api call and then go ahead only.

That means you need to send one key (may be auto generated alphanumeric string ) which is given by server in response of login api.