Blane Townsend
Blane Townsend

Reputation: 3048

How to pass API Key to a RestAPI from html form

I am making a RestAPI for my website and I want to use an API Key as part of my authentication. Let's say I have a form where a user creates a comment. Am I supposed to pass in the apiKey with the url? For instance,

<form method="POST" action="http://example.com/api/v1/comment?apiKey=12345">

These seems insecure since anybody can just view the html and see the apiKey. So, how is this supposed to work? How are you supposed to use an APIKey for security?

Upvotes: 1

Views: 1022

Answers (1)

Viktor A
Viktor A

Reputation: 146

You could use JavaScript/jQuery to do the post, which would allow you to add a HTTP header with your APIKey to the request.

Upvotes: 1

Related Questions