# Invalid\_client error

**URL:** <https://devforum.okta.com/t/invalid-client-error/23851>\
**Category:** Questions\
**Tags:** api\
**Created:** [April 4, 2023, 7:03am UTC](https://devforum.okta.com/t/invalid-client-error/23851 "2023-04-04T07:03:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mnibras](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@mnibras](https://devforum.okta.com/u/mnibras)\
**Post date:** [April 4, 2023, 7:03am UTC](https://devforum.okta.com/t/invalid-client-error/23851/1 "2023-04-04T07:03:43Z")

</div>

I have created an Okta application of type **API Services** and created a user from Okta directory  
I want to get the token for the created user

Below is my `curl` request to get the token

```auto
curl --request POST \
  --url 'https://dev-XXXXXX.okta.com/oauth2/default/v1/token' \
  --header 'content-type: application/x-www-form-urlencoded' \
  --data grant_type=password \
  --data scope='openid' \
  --data username=<user_email> \
  --data password=<Base64_encoded_password> \
  --data client_id=<client_id>

```

Response

```auto
{
    "error": "invalid_client",
    "error_description": "Client authentication failed. Either the client or the client credentials are invalid."
}

```

I’m sure that client-id and user credentials are correct.

Can anyone help me to resolve this?

---

<div class="post-metadata">

**Author:** ![dawoudt](https://avatars.discourse-cdn.com/v4/letter/d/ecb155/32.png) [@dawoudt](https://devforum.okta.com/u/dawoudt)\
**Post date:** [April 5, 2023, 6:03am UTC](https://devforum.okta.com/t/invalid-client-error/23851/2 "2023-04-05T06:03:07Z")

</div>

Hi @mnibras, checkout this example - [Implement authorization by grant type | Okta Developer](https://developer.okta.com/docs/guides/implement-grant-type/ropassword/main/#request-for-tokens)

It seems you need to pass you need to pass client credentials as basic auth (base 64 encoded). Your password will be plain text.

```auto

curl --request POST \
  --url https://${yourOktaDomain}/oauth2/default/v1/token \
  --header 'accept: application/json' \
  --header 'authorization: Basic MG9hYn...' \
  --header 'content-type: application/x-www-form-urlencoded' \
  --data 'grant_type=password&username=testuser1%40example.com&password=%7CmCovrlnU9oZU4qWGrhQSM%3Dyd&scope=openid'

```

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [February 13, 2024, 11:09pm UTC](https://devforum.okta.com/t/invalid-client-error/23851/3 "2024-02-13T23:09:22Z")

</div>

Closed on February 13, 2024, 11:09pm UTC


