This repository was archived by the owner on Jan 24, 2026. It is now read-only.
oAuth and File Upload support#451
Draft
Pezmc wants to merge 6 commits intosimplyspoke:masterfrom
Draft
Conversation
There are two ways to use oauth, by passing in a valid access token
when instantiating Node-Harvest or using the oAuth flow, calling
this.parseAccessCode() with an access code provided by Harvest after
hitting the URL in this.getAccessTokenURL().
Example usage:
```
var harvest_with_token = new Harvest({
subdomain: config.harvest_oauth.subdomain,
access_token: access_token
});
var TimeTracking = harvest.TimeTracking;
TimeTracking.daily({}, function(err, tasks) {
if (err) throw new Error(err);
console.log('Loaded tasks using passed in auth_token!');
});
```
or
```
var harvest = new Harvest({
subdomain: config.harvest_oauth.subdomain,
identifier: config.harvest_oauth.client_id,
secret: config.harvest_oauth.secret,
redirect_uri: config.harvest_oauth.redirect_uri
});
console.log('Visit the following and paste the access code param from
the url here', harvest.getAccessTokenURL());
rl.question("Code from the URL: ", function(answer) {
rl.close();
harvest.parseAccessCode(answer.trim(), function(access_token) {
console.log('Grabbed the access token', access_token);
var TimeTracking = harvest.TimeTracking;
TimeTracking.daily({}, function(err, tasks) {
if (err) throw new Error(err);
console.log('Loaded tasks using oauth!');
});
})
});
```
Usage example:
```
var options = {
id: config.expense_id,
file: {
path: 'path/to-my-image.jpeg',
originalname: 'original-name-of-my-image.jpeg'
}
}
Expenses.attachReceipt(options, function(err, reply) {
if (err) throw new Error(err);
console.log(reply);
});
```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a very old fork (~2015), just opening the draft PR to refer to it in #85