# 401 Invalid Authorization

**URL:** <http://forum.companieshouse.gov.uk/t/401-invalid-authorization/5186>\
**Category:** API Question\
**Created:** [June 26, 2022, 7:26pm UTC](http://forum.companieshouse.gov.uk/t/401-invalid-authorization/5186 "2022-06-26T19:26:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomas.c.smail](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/t/b487fb/32.png) [@thomas.c.smail](http://forum.companieshouse.gov.uk/u/thomas.c.smail)\
**Post date:** [June 26, 2022, 7:26pm UTC](http://forum.companieshouse.gov.uk/t/401-invalid-authorization/5186/1 "2022-06-26T19:26:20Z")

</div>

I tried using:  
`curl -u my_API_Key: "https://api.companieshouse.gov.uk/company/00048839"`  
to little success (getting “Invalid Authorization” error code), I had been using python and the request library but decided to try the command line as was facing the same error there. I can now see that it is not an issue with my python code and there instead must be an issue with either my application setup or some other factor that I am failing to see… does the “my\_API\_Key” have to be encoded somehow, base64 etc.?

---

<div class="post-metadata">

**Author:** ![voracityemail](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/v/b77776/32.png) [@voracityemail](http://forum.companieshouse.gov.uk/u/voracityemail)\
**Post date:** [June 26, 2022, 10:13pm UTC](http://forum.companieshouse.gov.uk/t/401-invalid-authorization/5186/2 "2022-06-26T22:13:33Z")

</div>

If you’re using curl no, you have it right. Your issue is probably one of the fields you asked about in your other question. I’ve posted there - hope that helps.

---

<div class="post-metadata">

**Author:** ![david6](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/d/22d042/32.png) [@david6](http://forum.companieshouse.gov.uk/u/david6)\
**Post date:** [July 5, 2022, 10:19am UTC](http://forum.companieshouse.gov.uk/t/401-invalid-authorization/5186/3 "2022-07-05T10:19:20Z")

</div>

Hi,  
I observed the same issue in Postman, trying to pass the ‘Authorization’ header with value 'Basic ’

Where is the Base64 encoded value for ‘my\_api\_key:’ (key value followed by colon), am I missing anything?

The response body I get is:  
{  
“error”: “Invalid Authorization”,  
“type”: “ch:service”  
}

---

<div class="post-metadata">

**Author:** ![voracityemail](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/v/b77776/32.png) [@voracityemail](http://forum.companieshouse.gov.uk/u/voracityemail)\
**Post date:** [July 5, 2022, 10:53am UTC](http://forum.companieshouse.gov.uk/t/401-invalid-authorization/5186/4 "2022-07-05T10:53:33Z")

</div>

Search the forum. First check you understand the live vs. sandbox environments when creating your application. (I posted something about this recently but can’t find it immediately. Over to you!)

Second - ensure you understand http basic authentication or how to make this work in Postman. Postman use has been covered on this forum, search around.

If you’re still having issues try this in the simplest tool you can e.g. curl would be good! LOTS of examples of how to debug this on the forum and Companies House use that in their documentation / examples too…

Good luck.

---

<div class="post-metadata">

**Author:** ![david6](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/d/22d042/32.png) [@david6](http://forum.companieshouse.gov.uk/u/david6)\
**Post date:** [July 5, 2022, 11:08am UTC](http://forum.companieshouse.gov.uk/t/401-invalid-authorization/5186/5 "2022-07-05T11:08:32Z")

</div>

Thanks! I checked other posts in this forum and managed to fix this thanks to your other comments! There were 2 issues: I was using a test app (instead of a live app), and I had to do the ‘localhost’ trick to allow requests to be executed from my laptop.

Thanks again!

---

<div class="post-metadata">

**Author:** ![mail2anilnalamothu](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/m/ac8455/32.png) [@mail2anilnalamothu](http://forum.companieshouse.gov.uk/u/mail2anilnalamothu)\
**Post date:** [September 30, 2022, 6:36pm UTC](http://forum.companieshouse.gov.uk/t/401-invalid-authorization/5186/6 "2022-09-30T18:36:19Z")

</div>

Yes, Thanks a lot. Two steps need to take care of.

1. Use Live app(instead of test app)
2. Use Basic Auth in postman and use your API Key as username (left password field as empty)
