# Unauthorized

**URL:** <https://community.hubspot.com/t/unauthorized/17347>\
**Category:** APIs & Integrations\
**Tags:** developer-tools\
**Created:** [November 21, 2019, 9:51pm UTC](https://community.hubspot.com/t/unauthorized/17347 "2019-11-21T21:51:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dianacch](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dianacch/32/48852_2.png) [@dianacch](https://community.hubspot.com/u/dianacch)\
**Post date:** [November 21, 2019, 9:51pm UTC](https://community.hubspot.com/t/unauthorized/17347/1 "2019-11-21T21:51:25Z")

</div>

i have a rest service is locate in a host with certificate http and i try to consume the api hubspot but when i send a request i have a issue.

this is the error:

**The remote server returned an error: 401 Unauthorized** , but in my local works fine.

I dont now what is the problem.

---

<div class="post-metadata">

**Author:** ![Derek\_Gervais](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/derek_gervais/32/17429_2.png) [@Derek\_Gervais](https://community.hubspot.com/u/Derek_Gervais)\
**Post date:** [November 22, 2019, 4:40pm UTC](https://community.hubspot.com/t/unauthorized/17347/2 "2019-11-22T16:40:45Z")

</div>

Hey @dianacch ,

Are you including the proper authentication with your requests to the HubSpot API? Each request requires either an API key (included as a query parameter, like this: `&hapikey=xxxx`) or an access token (included in the `Authorization` header, like this: `Bearer xxxxxxx`). If you have some more details about the requests that are failing, please don’t hesitate to post them here (without any sensitive authentication details) and we can help troubleshoot what’s going on.

You can find some more details on authentication here: [Accounts Dashboard | HubSpot](https://developers.hubspot.com/docs/methods/auth/oauth-overview)

---

<div class="post-metadata">

**Author:** ![dianacch](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dianacch/32/48852_2.png) [@dianacch](https://community.hubspot.com/u/dianacch)\
**Post date:** [November 22, 2019, 5:50pm UTC](https://community.hubspot.com/t/unauthorized/17347/3 "2019-11-22T17:50:31Z")

</div>

[@Derek\_Gervais](https://community.hubspot.com/t5/user/viewprofilepage/user-id/142) yes, i send the **api key** in the request:  
**[https://api.hubapi.com/contacts/v1/contact/?hapikey=apikey](https://api.hubapi.com/contacts/v1/contact/?hapikey=apikey)**

When i send a request from my localhost works fine but when my service is hosting in a host without certificate https doesn’t works.

The certificate is the problem ? Is it necessary have a host with certificate https ??

---

<div class="post-metadata">

**Author:** ![Derek\_Gervais](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/derek_gervais/32/17429_2.png) [@Derek\_Gervais](https://community.hubspot.com/u/Derek_Gervais)\
**Post date:** [December 3, 2019, 3:18pm UTC](https://community.hubspot.com/t/unauthorized/17347/4 "2019-12-03T15:18:23Z")

</div>

Hi @dianacch ,

Apologies for the delay here. As far as I understand, it’s not required that your client has an SSL certificate in order to make requests to the HubSpot API. This appears to be validated in this [stack overflow article](https://security.stackexchange.com/questions/110621/ssl-newbie-does-https-client-also-need-a-certificate). That said, I’m not really clear on what exactly is happening here. A 401 with a hapikey almost always means one of two things:

1. The request is being malformed in some way, so that the hapikey isn’t being properly included
2. The hapikey is a developer hapikey (from a developer account) and is used to make requests to a test or production portal

Can you potentially log the raw request body you’re sending to the HubSpot API (minus the actual hapikey) so that we can take a closer look? Additionally, can you confirm the Hub ID of the account you’re using?

---

<div class="post-metadata">

**Author:** ![dianacch](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dianacch/32/48852_2.png) [@dianacch](https://community.hubspot.com/u/dianacch)\
**Post date:** [December 3, 2019, 7:29pm UTC](https://community.hubspot.com/t/unauthorized/17347/5 "2019-12-03T19:29:18Z")

</div>

Thanks a lot [@Derek\_Gervais](https://community.hubspot.com/t5/user/viewprofilepage/user-id/142), your post saved me.

The problem was in the host configuration hahahaha
