bullhorn / taurus

Typescript client for the Bullhorn REST API
MIT License
10 stars 6 forks source link

Attempt to authenticate so I can query candidates in the system #49

Open bnbon opened 4 years ago

bnbon commented 4 years ago

Hi,

I am using React (react-boilerplate) and this library with the intention to allow visitors to a website to query the candidates in the bullhorn system.

I am aware I will need to hide the variables in use by the system, but regardless I just want to do the above first in a rough and ready way initially.

This is the code I have, with obvious omissions, but the URL for login returns a 404 – yet it is taken exactly from the docs.

import React, { Component } from 'react';
import { Staffing, StaffingCredentialsAuthProvider } from '@bullhorn/taurus';

const provider = new StaffingCredentialsAuthProvider(
  'USERNAME',
  'PASSWORD',
);

const staffing = new Staffing({
  useCookies: false,
  client_id: 'CLIENT_ID',
  apiVersion: '*',
  redirect_url: 'http://0.0.0.0:3000',
  authorization_url: 'http://auth.bullhornstaffing.com/oauth/authorize',
  token_url: 'http://auth.bullhornstaffing.com/oauth/token',
  login_url: 'http://rest.bullhornstaffing.com/rest-services/login',
});

class SearchPage extends Component {
  doSearch = () => {
    console.log(`Login Attempt`);

    staffing.login(provider).then(() => {
      console.log('2');
      // never reached
    });

    console.log('1');
  };

  render() {
    this.doSearch();

    return (
      <>
          <h1>search</h1>
      </>
    );
  }
}

export default SearchPage;

Are these urls different now - or am I making a mess of this; the documentation is a little unclear, but I would have thought search candidates from the system would be quite straight forward?

Many Thanks