Cannot refresh token

Hello

I have an integration app that is working getting the access token fetching data.
However I am having trouble refreshing the token and I am getting an error:
{“success”:false,“error”:“unauthorized access”,“errorCode”:401,“error_info”:“Please check developers.pipedrive.com”} .

The c# code I am using is as below, can someone see what I am doing wrong?

request = new RestRequest(TOKEN_REQUEST_URL, Method.Post);
string postParams = $"grant_type=refresh_token&refresh_token={integration.RefreshToken}";
string postHeader = "Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes($"{OauthAppId}:{OauthAppSecret}"));

request.AddParameter("application/x-www-form-urlencoded", postParams, ParameterType.RequestBody);
request.AddHeader("Authorization", postHeader);

response = await client.ExecuteAsync<PipedriveTokenRefreshModel>(request);

Thanks

Hi! What is the value of TOKEN_REQUEST_URL? Your code snippet seems to work fine if I try it with this URL: https://oauth.pipedrive.com/oauth/token as documented here.

string TOKEN_REQUEST_URL = “https://oauth.pipedrive.com”;
postUrl = $“{TOKEN_REQUEST_URL}/oauth/token”;

Hi,

Corrected the URL and it refreshed fine.

// old code
request = new RestRequest(TOKEN_REQUEST_URL, Method.Post);

should have been


string TOKEN_REQUEST_URL = “https://oauth.pipedrive.com”;

postUrl = $“{TOKEN_REQUEST_URL}/oauth/token”;

request = new RestRequest(postUrl, Method.Post);


Thanks for confirming that everything else was correct and pointing me to the url
1 Like