2021年4月3日星期六

How to properly put the auth token in the header for a GET request

I have am trying to do a get request to api with blockcypher.com. In the docs they simply append the api token to the URL with ?token= or if it's part of multiple parameters &token=. What's the proper protocol for putting this in the headers to make sure that the token isn't sent in the URL for security reasons?

I already tried to do this formula

var client = _clientFactory.CreateClient(nameof(<Parent Function Name>));  client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", <API Token Here>);  

This didn't work. My blockcypher account claims that no requests to my API were sent when I use the above code.

https://stackoverflow.com/questions/66937430/how-to-properly-put-the-auth-token-in-the-header-for-a-get-request April 04, 2021 at 10:05AM

没有评论:

发表评论