# Converting to PrivateApp: "Authentication credentials not found." - Using Powershell

**URL:** <https://community.hubspot.com/t/converting-to-privateapp-authentication-credentials-not-found-using-powershell/69598>\
**Category:** APIs & Integrations\
**Tags:** contacts\
**Created:** [November 18, 2022, 5:51pm UTC](https://community.hubspot.com/t/converting-to-privateapp-authentication-credentials-not-found-using-powershell/69598 "2022-11-18T17:51:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SeeOurBeach](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/seeourbeach/32/99949_2.png) [@SeeOurBeach](https://community.hubspot.com/u/SeeOurBeach)\
**Post date:** [November 18, 2022, 5:51pm UTC](https://community.hubspot.com/t/converting-to-privateapp-authentication-credentials-not-found-using-powershell/69598/1 "2022-11-18T17:51:58Z")

</div>

Hi -

We are working to convert our API scripts to use the PrivateApp. Set up the PrivateApp. Got the token key. Tried a simple call. Got the error message "“Authentication credentials not found. This API supports both API Key and OAuth 2.0 authentication”.

Looking over examples and documentation and cant figure out. Am I missing something obvious?

Code:

$PrivateAppKey=“…(not shown)…”;

$url = “[https://api.hubapi.com/crm/v3/objects/contacts/123456789](https://api.hubapi.com/crm/v3/objects/contacts/123456789)”; # (obfuscated)

$headers = @{ ‘Content-Type’=‘application/json’  
‘Authorization’= 'Basic ’ + $PrivateAppKey  
}

$JSONStr=‘{“properties”:[{“property”:“Alink”,“value”:“[https://www.someothersytsem.com](https://www.someothersytsem.com)”}]}’;

$response = Invoke-WebRequest -Uri $url -UseBasicParsing -Body $JSONstr -Headers $Headers -Method ‘PATCH’;

#Methods that fail: UPDATE, POST, GET

Response:

{“status”:“error”,“message”:"Authentication credentials not found. This API supports both API Key and OAuth 2.0 authentication and you can find more details at  
[https://developers.hubspot.com/docs/methods/auth/oauth-overview",“correlationId”:“27ded0ae-876c-4383-8129-0b3c7b64a83f”,“category”:“INVALID\_AUTHENTICATION”}](https://developers.hubspot.com/docs/methods/auth/oauth-overview%22,%22correlationId%22:%2227ded0ae-876c-4383-8129-0b3c7b64a83f%22,%22category%22:%22INVALID_AUTHENTICATION%22%7D)

Thanks!

---

<div class="post-metadata">

**Author:** ![skimura](https://avatars.discourse-cdn.com/v4/letter/s/9de053/32.png) [@skimura](https://community.hubspot.com/u/skimura)\
**Post date:** [November 19, 2022, 11:59am UTC](https://community.hubspot.com/t/converting-to-privateapp-authentication-credentials-not-found-using-powershell/69598/2 "2022-11-19T11:59:33Z")

</div>

@SeeOurBeach

Hi.

How about this?

```lia-code-sample
$headers = @{ 'Content-Type'='application/json'
 'Authorization'= 'Bearer ' + $PrivateAppKey
}

```

`Authorization: Basic XXXX` means basic auth.

private app token is used by oauth2.

so , it should set `Authorization: Bearer XXXX` in header.

Thanks.

---

<div class="post-metadata">

**Author:** ![SeeOurBeach](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/seeourbeach/32/99949_2.png) [@SeeOurBeach](https://community.hubspot.com/u/SeeOurBeach)\
**Post date:** [November 21, 2022, 4:06pm UTC](https://community.hubspot.com/t/converting-to-privateapp-authentication-credentials-not-found-using-powershell/69598/3 "2022-11-21T16:06:24Z")

</div>

Perfect!  
Thanks for that advice
