Trouble getting Authorization Code programatically

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

Moderators: StaffingSupport, s.emmons, BullhornSupport

mhuggins
User
Posts: 10
Joined: Mon Feb 25, 2019 10:06 am

Re: Trouble getting Authorization Code programatically

Post by mhuggins » Wed Jun 12, 2019 8:41 pm

Hi lloydevaporate,

Could you please detail further what issues you are having with the responses from the API?

- Max

lloydevaporate
User
Posts: 11
Joined: Fri May 17, 2019 8:20 am
Contact:

Re: Trouble getting Authorization Code programatically

Post by lloydevaporate » Fri Jun 14, 2019 8:14 am

I got there eventually, it was a mixture of sometimes html responses, json or it would be in the header but I got it working.

New issue I've come across after moving to my staging environment however is that this url
https://auth.bullhornstaffing.com/oauth ... ENT_SECRET is returning a 404 however this is the exact same url that was used in my local environment.

Any help with this would be appreciated as I don't understand why this is happening. Below is the code that uses this route

Code: Select all

        
        $params = [
        CURLOPT_FOLLOWLOCATION => 0,
        CURLOPT_RETURNTRANSFER => 1,
        CURLOPT_MAXREDIRS => 0,
        CURLOPT_POST => 1
    ];
        // string|null $authcode
        // string|null $refresh 
        $code = $refresh ?? $authCode ?? AuthCode::get();
        if (!$code)
            return null;
        $type = $refresh == null ? 'authorization_code&code' : 'refresh_token&refresh_token';
        $config = parse_ini_file('config.ini');
        $client = $config['CLIENT_ID'];
        $secret = $config['CLIENT_SECRET'];
        $url = $config['OAUTH_URL'];

        //die("$url/token?grant_type=$type=$code&client_id=$client&client_secret=$secret");

        $ch = curl_init("$url/token?grant_type=$type=$code&client_id=$client&client_secret=$secret");
        curl_setopt_array($ch, AccessToken::$params);

agrossman
User
Posts: 10
Joined: Thu Jul 19, 2018 12:21 pm

Re: Trouble getting Authorization Code programatically

Post by agrossman » Mon Jun 17, 2019 12:12 pm

Hi lloydevaporate,

It looks like you are using outdated endpoints in your authorization call. Please try updating your endpoints to the specific one needed for your data center, which can be found here: http://bullhorn.github.io/Data-Center-URLs/

Please let me know if this resolves the issue or if you have any further questions!
Alice Grossman
Enterprise Support Analyst
B U L L H O R N

Bullhorn Support Contact Numbers
US: 617-478-9126
UK: 44 800 032 2848
Australia: 61 28 073 5089
International: 617-478-9131

lloydevaporate
User
Posts: 11
Joined: Fri May 17, 2019 8:20 am
Contact:

Re: Trouble getting Authorization Code programatically

Post by lloydevaporate » Tue Jun 18, 2019 3:45 am

Hi,

In the time it took for the post to be approved I sorted out my issue.

I'm using the prefixed domains as I was led to believe that they are static, post sign-in I get the restUrl which is then used for all subsequent calls.

For anyone struggling to get this working I'm going to provide my code here >> https://hastebin.com/fatatupaji.php <<

Yes I'm aware there's a lot that I could do better but it works for the time being, it's written for simple syntax eg.

Code: Select all

AuthCode::get() RestToken::refresh()
Feel free to pull it apart, wouldn't have been able to do it without these forums so feels only right to give it back.

Cheers,
Lloyd

agrossman
User
Posts: 10
Joined: Thu Jul 19, 2018 12:21 pm

Re: Trouble getting Authorization Code programatically

Post by agrossman » Tue Jun 18, 2019 10:44 am

Hi lloydevaporate,

I am so glad you were able to figure it out and thank you for sharing your code for the benefit of others! Please let us know if you have any further questions!
Alice Grossman
Enterprise Support Analyst
B U L L H O R N

Bullhorn Support Contact Numbers
US: 617-478-9126
UK: 44 800 032 2848
Australia: 61 28 073 5089
International: 617-478-9131

Post Reply