OAuth 2 provider returned an error: Invalid grant: refresh token is invalid

Today our users started receiving such message:

	"errorMessage": "OAuth 2 provider returned an error.",
	"errorCode": 400,
	"errorResponse": {
		"reason": "OAuth 2 provider returned an error.",
		"context": {
			"request": {
				"queryUrl": "https://oauth.pipedrive.com/oauth/token",
				"method": "POST",
				"headers": {
					"accept": "application/json",
					"Authorization": "Basic ZWVhODJkOTgyZGE3YTJiOxiY2JiNDxxxxxQ0YWYyODliOTg4MTM2ZGE5OTQ3ZTZiZDJlNTA5NDlm",
					"user-agent": "Pipedrive-SDK-Node-10.6.0",
					"content-type": "application/x-www-form-urlencoded"
				"form": {
					"grant_type": "refresh_token",
					"refresh_token": "7454116:12114342:ab09cb251xxxxx67b0744f63762cf89954a23d19",
					"scope": ""
			"response": {
				"statusCode": 400,
				"body": "{\"success\":false,\"message\":\"Invalid grant: refresh token is invalid\",\"error\":\"invalid_grant\"}",
				"headers": {
					"date": "Fri, 14 May 2021 11:12:09 GMT",
					"content-type": "application/json; charset=utf-8",
					"content-length": "93",
					"connection": "close",
					"cf-ray": "64f3b09b7918112d-MAD",
					"access-control-allow-origin": "https://oauth.pipedrive.com",
					"cache-control": "no-cache",
					"strict-transport-security": "max-age=31536000; includeSubDomains",
					"cf-cache-status": "DYNAMIC",
					"access-control-allow-credentials": "true",
					"access-control-expose-headers": "X-RateLimit-Remaining, X-RateLimit-Limit, X-RateLimit-Reset",
					"badi": "Routing: eu-central-1=>eu-central-1; Version: 5f05; Host: bari;",
					"cf-request-id": "0a0c2cb52b0000112df8b68000000001",
					"content-security-policy": "default-src 'self';base-uri 'self';block-all-mixed-content;font-src 'self' https: data:;frame-ancestors 'self';img-src 'self' data:;object-src 'none';script-src 'self';script-src-attr 'none';style-src 'self' https: 'unsafe-inline';upgrade-insecure-requests",
					"expect-ct": "max-age=0",
					"pdtrusted-wgw-real-user-ip": "",
					"referrer-policy": "no-referrer",
					"x-content-type-options": "nosniff",
					"x-correlation-id": "e3622af7-1a0f-4003-89fb-3ecaeb2fcc11",
					"x-dns-prefetch-control": "off",
					"x-download-options": "noopen",
					"x-frame-options": "SAMEORIGIN",
					"x-permitted-cross-domain-policies": "none",
					"x-xss-protection": "0, 1; mode=block",
					"set-cookie": ["__cf_bm=b129f0ba7114e85380f6b3767338011e8ce7f137-1620990729-1800-AXV9TE5W0Gz8k7xHNferdFqf3nBidsxIhmiT8V2T9v5aADRgB3Kad3xM9tlIMxqPrPyYAcKQrD0vdVmTOhKMLRg=; path=/; expires=Fri, 14-May-21 11:42:09 GMT; domain=.pipedrive.com; HttpOnly; Secure; SameSite=None"],
					"server": "cloudflare",
					"alt-svc": "h3-27=\":443\"; ma=86400, h3-28=\":443\"; ma=86400, h3-29=\":443\"; ma=86400"
		"error": "invalid_grant",
		"errorDescription": null,
		"errorUri": null

Im sure that it worked absolutely normally before and nothing changed in the code and our logic. We are using NodeJS and official SDK → pipedrive - npm and it seems everything should be refreshed under the hood of SDK automatically. Could you please assist what is going on? I have several the same problems from our customers.

Hi @Dmitriy_Suhinin1 ,

It seems like a user uninstalled the app, hence you can’t refresh it and get a new access token.

Are you handling uninstallation flow?

hey @mykhailo! thank you for you response!

Yep, we are handling this situation on our side but I still can see auth data that means that user didn’t uninstall his app. I can see a lot of almost the same topics related to my issues but without any advice about what is going on. So Im not sure that this problem related to uninstall process itself.

Hello @Dmitriy_Suhinin1 ,

What is app’s client_id (public id)? So I could check if the uninstall callback was called on our side.

@mykhailo → eea82d982da7a2b8