bad request when trying to refresh token

Forum for users and developers of Bullhorn's API service.

Moderators: StaffingSupport, s.emmons, BullhornSupport

Post Reply
gswartz777
User
Posts: 10
Joined: Tue Jun 09, 2020 8:26 am

bad request when trying to refresh token

Post by gswartz777 »

I'm using the following code to refresh the access token. When it hits the request.GetResponse() I get a bad request exception. Any ideas why this is happening? Thanks.

Code: Select all

var url =
    $@"https://auth.bullhornstaffing.com/oauth/token?grant_type=refresh_token&refresh_token={refreshToken}&client_id={BullhornConstants.ClientId}&client_secret={BullhornConstants.ClientSecret}";
var request = WebRequest.CreateHttp(url);
request.Method = "POST";
request.Accept = "application/json";
var responseObj = (HttpWebResponse) request.GetResponse();

using (var streamReader = new StreamReader(responseObj.GetResponseStream()))
{
    if (responseObj.StatusCode == HttpStatusCode.OK)
    {
        var content = streamReader.ReadToEnd();
        var tokens = JsonConvert.DeserializeObject<BullhornToken>(content);
        return tokens;
    }
}

return null;

bbagwell
User
Posts: 16
Joined: Wed Feb 26, 2020 12:17 pm

Re: bad request when trying to refresh token

Post by bbagwell »

Hello. Please see http://bullhorn.github.io/Getting-Started-with-REST/

Use a refresh token to get a new access token
To obtain an access token with a refresh token, make a POST request with the following URL, substituting your actual values for the placeholders in the query parameters:

Code: Select all

https://auth.bullhornstaffing.com/oauth/token?grant_type=refresh_token&refresh_token={refresh_token}&client_id={client_id}&client_secret={client_secret}

gswartz777
User
Posts: 10
Joined: Tue Jun 09, 2020 8:26 am

Re: bad request when trying to refresh token

Post by gswartz777 »

That's exactly what I'm doing when it throws the error.

bbagwell
User
Posts: 16
Joined: Wed Feb 26, 2020 12:17 pm

Re: bad request when trying to refresh token

Post by bbagwell »

Can you please submit a support ticket with the exact call. For privacy reasons, I don't want you to post this on the forum. We will need to see if we can replicate the issue.

gswartz777
User
Posts: 10
Joined: Tue Jun 09, 2020 8:26 am

Re: bad request when trying to refresh token

Post by gswartz777 »

I removed the refresh token from our end to force a new login. Since that I haven't had an issue, so can't reproduce. I'll let you know if it comes up again. Thanks.

bbagwell
User
Posts: 16
Joined: Wed Feb 26, 2020 12:17 pm

Re: bad request when trying to refresh token

Post by bbagwell »

OK!

Post Reply