I am working to provide a REST API for a service. One issue that I am struggling with is the authentication aspect. I have inspected some other libraries and I noticed a strategy as follows:
Server side:
app.post("get_dogs"){
SecretKey = Authorization Header
if SecretKey in Database{
dogs = Database[SecretKey]
return dogs;
}
return "Not found!!";
}
Client Side:
request = post("www.random.com/get_dogs")
request.authentication_header = SECRET KEY
response = request.send()
My question is: is this technique secure? I am sending the secret key in the authentication header. If someone seen the secret key, then they could have access to that user's account. One solution could be hashing, but then again - I am not quite sure.
Any advice would be greatly appreciated!