Skip to content
This repository has been archived by the owner on Feb 19, 2024. It is now read-only.

Access token #2

Open
stygiansabyss opened this issue Apr 27, 2016 · 5 comments
Open

Access token #2

stygiansabyss opened this issue Apr 27, 2016 · 5 comments

Comments

@stygiansabyss
Copy link

Once gathered, it seems as though it can expire. How do you get around this?

@mboynes
Copy link

mboynes commented Sep 16, 2016

@stygiansabyss did you ever figure this out?

@stygiansabyss
Copy link
Author

I did not. I basically abandoned hope at this point. I could not find a feasible way to automate this.

@nilsnh
Copy link

nilsnh commented Nov 7, 2016

Could maybe retrieve a token by steering a browser at https://id.getharvest.com/ , automatically clicking the right login buttons and getting the token from the browser url? More info about their new id portal: link.

@DelanoRochan
Copy link

DelanoRochan commented May 19, 2017

@stygiansabyss @mboynes @nilsnh Yes, that works, e.g. like this:

console.time("Execution");

const Nightmare = require('nightmare');		
const nightmare = Nightmare({ show: false });
const Forecast = require('forecast-api');

const hostUrl = 'https://id.getharvest.com/sessions/new';
const userName = '<Your username>';
const userPassword = '<Your password>';

var userId = '';
var userToken = '';

nightmare
  .goto(hostUrl)
  .insert('#email', userName)
  .insert('#password', userPassword)
  .click('#log-in')
  .wait('.ember-application')
  .url()
  .end()
  .then(function (result) {
    temp = result.split('/');
    userId = temp[3];
    userToken = 'Bearer ' + temp[5];
    console.log(userId);
    console.log(userToken);
    console.timeEnd("Execution");
  })
  .catch(function (error) {
    console.error('Search failed:', error);
  });

@tjschuck
Copy link

Forecast now supports authenticating using either Personal Access Tokens or full-fledged OAuth2. Documentation here: http://help.getharvest.com/api-v2/authentication-api/authentication/authentication/

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants