Request failed with status code 400

Hello everyone,

I have an issue with refresh_token endpoint, and PD support do not know what is the problem, so I am trying to ask here:).

Since last week I got error when I am trying to refresh_token with error 400 and response is “{
“success”: false,
“message”: “Missing parameter: grant_type”,
“error”: “invalid_request”
}”.
In my request seems everything to be allright, but here is details:

URL: https://oauth.pipedrive.com/oauth/token
Headers: authorization (KEY); Content-Type (application/x-www-form-urlencoded)
Search params: grant_type “refresh_token” and refresh_token “VALUE_OF_TOKEN”

In a lot of emails I’ve written with support, I’ve tried options like putting REFRESH_TOKEN instead of refresh_token or adding garant_type and refresh_token to the request body instead of in search params (and more)… Nothing work for me, so I was redirected to this community.

Does anyone know what should be that issue? :slight_smile:

Thank you a lot.

Best Regards,
Jakub Kozler

1 Like

Hello, @Jakub_Kozler and welcome to the community! :wave:

From the error response, it seems that you are missing the grant_type parameter in your request.

Here’s a cURL example for the request:

curl --request POST \
  --url https://oauth.pipedrive.com/oauth/token \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data client_id=CLIENT_ID \
  --data client_secret=CLIENT_SECRET \
  --data refresh_token=REFRESH_TOKEN \
  --data grant_type=refresh_token

Let us know if you have further questions!
Helena

Hello, @Helena_Sul for helping. Yes, now I get different error:

{
    "success": false,
    "message": "Invalid grant: refresh token is invalid",
    "error": "invalid_grant"
}

I think that refresh_token is valid, do you know what to do with this error?

Best regards,
Jakub Kozler

Hey, @Jakub_Kozler

This means that the refresh_token is invalid. There’s a couple possible reasons why:

  • the user uninstalled the app
  • the user re-installed the app and got a new refresh token

Sincerely,
Helena

Hello!

We’re having the same problem, but the user did not delete the application or reinstall it. What should we do? This problem occurs periodically, not every installation.