Unable to authenticate username and password

Hello,
I have use Ruby, but got an error “Unable to authenticate username and password”
Don’t understand what is wrong?
Please clarify

data = {
  client_id: "my_client_id",
  client_secret: "my_client_secret",
  grant_type: "authorization_code",
  redirect_uri: "my_redirect_uri"
}

response = Faraday.post( "https://api.infusionsoft.com/token") do | req |
  req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
  req.body = URI.encode_www_form(data)
end

response_body = JSON.parse(response.body)

my response is:
{“error”=>“invalid_grant”, “error_description”=>“Unable to authenticate username and password”}

POSTMAN send me same error

We currently have a bug that causes the incorrect error to be returned, so the real error is obscured.

It looks like you are not sending the code value you during the authorization. Also you need to provide a valid redirect_uri

I have remove code from header and update redirect-uri… the problem the same.

could you send a working example parameters where I can put my client_id and client_secret and it will work

Cause now I can’t understand what is wrong?

Why are you removing the code param. It needs to be there with the valid authorization code you receive with asking for authorization. Please make sure you are following the spec https://tools.ietf.org/html/rfc6749#section-4.1

Another thing I can see in your console that you are sometimes sending the wrong client_id in the authorization step. Make sure you use the key and secret under API Keys in the portal for your client_id and client_secret. Also I don’t see you sending a redirect_uri in the original authorization (this is required). You must then send the exact same redirect_uri along with the code returned in order to get an access and refresh tokens.