Invalid_client error

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

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

{
    "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?

Hi @mnibras, checkout this example - Implement authorization by grant type | Okta Developer

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


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'
1 Like