Open dannysmith opened 9 years ago
It seems that res.headers doesn't contain 'location'.
I was able to fix the issue by hitting the API in a browser at https://auth.bullhornstaffing.com/oauth/authorize?action=Login&client_id=XXX&response_type=code&username=XXX
without sending the password parameter and manually typing the password.
I've not used the Bullhorn API before, and it looks like this is a required step if that's the case. It might be worth updating the README.
I have seen the same thing, did a bit of digging and testing. If you repeatedly call the bullhorn api you eventually get this error, I think it's probably a race condition on their side
If authorize fails location is almost always set to:
"location"=>
"http://auth.bullhornstaffing.com/bullhorn-oauth-services-2.0/www.bullhorn.com?error=server_error&error_description=Timer+already+cancelled.",
See the BH forum: https://supportforums.bullhorn.com/viewtopic.php?t=15227 https://supportforums.bullhorn.com/viewtopic.php?t=15597
in my fork of the repo my authorize
method now looks like this:
def authorize
url = "https://#{self.auth_host}/oauth/authorize"
params = {
client_id: client_id,
username: username,
password: password,
action: 'Login',
response_type: 'code'
}
#Note: Sometimes we get a 500 from the server saying "Timer already cancelled".
#https://supportforums.bullhorn.com/viewtopic.php?t=15227
#https://supportforums.bullhorn.com/viewtopic.php?t=15597
#In this case we retry until it works, with a timeout
Timeout.timeout(30) {
loop do
res = auth_conn.get url, params
location = res.headers['location']
self.auth_code = CGI::parse(URI(location).query)["code"].first
break if self.auth_code
end
}
end
I've hit the API pretty hard since adding this and zero errors so far! :)
Will raise a PR against the main repo in case people want that fix.
Having read #2, I tried installing bullhorn-rest from source, but am getting an error:
Here's my code:
It's obviously being caused by these lines in authorise.rb (line 25):
Presumably
location
is either nil or not in the correct format. I'll fork and do some more digging.