Skip to content

Commit

Permalink
Merge pull request #52 from intuit/develop
Browse files Browse the repository at this point in the history
2.0.0
  • Loading branch information
abisalehalliprasan authored Oct 18, 2019
2 parents cff9bdf + 3685c8f commit 4969620
Show file tree
Hide file tree
Showing 16 changed files with 824 additions and 365 deletions.
36 changes: 28 additions & 8 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,33 @@
"sourceType": "script"
},
"rules": {
"strict": ["error", "safe"],
"prefer-object-spread": "off",
"no-param-reassign": "off",
"comma-dangle": ["error", {
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "always-multiline",
"exports": "always-multiline",
"functions": "never"
}]
"comma-dangle": [
"error",
{
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "always-multiline",
"exports": "always-multiline",
"functions": "never"
}
],
"no-underscore-dangle": "off",
"no-unused-expressions": "off"
},
"globals": {
"sinon": true,
"describe": true,
"it": true,
"expect": true,
"test": true,
"require": true
},
"env": {
"es6": true,
"node": true,
"mocha": true
}
}
}
28 changes: 28 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Node CI

on:
push:
branches:
- develop

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [8.x, 10.x, 12.x]

steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install, build, and test
run: |
npm install
npm test
env:
CI: true
7 changes: 6 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
# IDE
.idea
.idea/
.vscode

# Samples
sample
test

# Source files
src/index.js
src/logs

# Configuration files
.travis.yml
.eslintrc.json
.eslintignore

2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package-lock=false
registry=https://registry.npmjs.org
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ node_js:
- 9
- 8
- 7
- 6

before_script:
- npm install
Expand All @@ -13,3 +12,4 @@ script:
- npm test

after_script: NODE_ENV=test istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage

100 changes: 80 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

[![Build Status](https://travis-ci.org/intuit/oauth-jsclient.svg?branch=master)](https://travis-ci.org/intuit/oauth-jsclient)
[![NPM Package Version](https://img.shields.io/npm/v/intuit-oauth.svg?style=flat-square)](https://www.npmjs.com/package/intuit-oauth)
[![Coverage Status](https://coveralls.io/repos/github/intuit/oauth-jsclient/badge.svg?branch=master)](https://coveralls.io/github/intuit/oauth-jsclient?branch=master)

# Intuit OAuth2.0 NodeJS Library

Expand All @@ -11,30 +12,43 @@ The OAuth2 Nodejs Client library is meant to work with Intuit's [OAuth2.0](https

## Table of Contents

- [Intuit OAuth2.0 NodeJS Library](#intuit-oauth20-nodejs-library)
- [Table of Contents](#table-of-contents)
- [Requirements](#requirements)
- [Installation](#installation)
- [Using NodeJS](#using-nodejs)
- [Options :](#options)
- [Usage](#usage)
- [Authorization Code flow](#authorization-code-flow)
- [Sample](#sample)
- [Helpers](#helpers)
- [Is Access Token valid](#is-accesstoken-valid)
- [Refresh Access_Token](#refresh-access_token)
- [Refresh Access_Token by passing the refresh_token explicitly](#refresh-access_token_explicitly)
- [Revoke Access Token](#revoke-access_token)
- [Getter / Setter for Token](#getter-/-setter-for-token )
- [Auth Response](#auth-response)
- [Error Logging](#error-logging)
- [Contributing](#contributing)
- [Authors](#authors)
- [Contributors](#contributors)
- [Changelog](#changelog)
- [License](#license)
- [Authorization Code Flow](#authorization-code-flow)
- [Step 1](#step-1)
- [Scopes :](#scopes)
- [Step 2](#step-2)
- [Sample](#sample)
- [Helpers](#helpers)
- [Is AccessToken Valid](#is-accesstoken-valid)
- [Refresh access_token](#refresh-access_token)
- [Refresh access_token by passing the refresh_token explicitly](#refresh-access_token-by-passing-the-refresh_token-explicitly)
- [Revoke access_token](#retrieve-the-token-)
- [Getter / Setter for Token](#getter--setter-for-token)
- [Retrieve the Token :](#retrieve-the-token)
- [Set the Token :](#set-the-token-)
- [Migrate OAuth1.0 Tokens to OAuth2.0](#migrate-oauth10-tokens-to-oauth20)
- [Validate ID Token](#validate-id-token)
- [Make API call](#make-api-call)
- [Auth-Response](#auth-response)
- [Error Logging](#error-logging)
- [FAQ](#faq)
- [Contributing](#contributing)
- [Steps](#steps)
- [Changelog](#changelog)
- [License](#license)


# Requirements

The Node.js client library is tested against the `Node` >= `6.0.0`
The Node.js client library is tested against the `Node` >= `7.0.0`

To use in node 6, please use [[email protected].](https://github.com/intuit/oauth-jsclient/tree/1.5.0) Older node versions are unsupported.

# Installation

Expand All @@ -61,7 +75,7 @@ Follow the instructions below to use the library :
});
```

### Options :
### Options

* `clientId` - clientID for your app. Required
* `clientSecret` - clientSecret fpor your app. Required
Expand Down Expand Up @@ -104,7 +118,7 @@ const authUri = oauthClient.authorizeUri({scope:[OAuthClient.scopes.Accounting,O
res.redirect(authUri);
```
### Scopes :
### Scopes

The available scopes include :

Expand Down Expand Up @@ -223,7 +237,7 @@ oauthClient.revoke()
});
```
Alternatively you can also pass `access_token` or `refresh_token` to this helper method using the `params` object: refer to - [Getter / Setter for Token](#getter-/-setter-for-token ) section to know how to retrieve the `token` object
Alternatively you can also pass `access_token` or `refresh_token` to this helper method using the `params` object: refer to - [Getter / Setter for Token](#getter--setter-for-token ) section to know how to retrieve the `token` object
```javascript
oauthClient.revoke(params)
Expand Down Expand Up @@ -359,6 +373,52 @@ You can validate the ID token obtained from `Intuit Authorization Server` as sho
The client validates the ID Token and returns boolean `true` if validates successfully else it would throw an exception.
### Make API Call
You can make API call using the token generated from the client as shown below :
```javascript
// Body sample from API explorer examples
const body = {
TrackQtyOnHand: true,
Name: "Garden Supplies",
QtyOnHand: 10,
InvStartDate: "2015-01-01",
Type: "Inventory",
IncomeAccountRef: {
name: "Sales of Product Income",
value: "79"
},
AssetAccountRef: {
name: "Inventory Asset",
value: "81"
},
ExpenseAccountRef: {
name: "Cost of Goods Sold",
value: "80"
}
};
oauthClient.makeApiCall({
url: 'https://sandbox-quickbooks.api.intuit.com/v3/company/1234/item',
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(body)
}).then(function(response){
console.log('The API response is : ' + response);
})
.catch(function(e) {
console.log('The error is '+ JSON.stringify(e));
});
```
The client validates the ID Token and returns boolean `true` if validates successfully else it would throw an exception.
### Auth-Response
Expand Down Expand Up @@ -489,7 +549,7 @@ You can refer to our [FAQ](https://github.com/intuit/oauth-jsclient/wiki/FAQ) if
## Changelog
See the changelog [here]()
See the changelog [here](https://github.com/intuit/oauth-jsclient/blob/master/CHANGELOG.md)
## License
Expand Down
25 changes: 17 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "intuit-oauth",
"version": "1.5.0",
"description": "Intuit Node.js client for OAuth2.0 and OpenID",
"version": "2.0.0",
"description": "Intuit Node.js client for OAuth2.0 and OpenIDConnect",
"main": "./src/OAuthClient.js",
"scripts": {
"start": "node index.js",
Expand All @@ -11,6 +11,8 @@
"fix": "eslint . --fix",
"posttest": "nyc check-coverage",
"test-watch": "mocha --watch --reporter=spec",
"test-debug": "mocha --inspect-brk --watch test",
"show-coverage": "npm test; open -a 'Google Chrome' coverage/index.html",
"clean-install": "rm -rf node_modules && npm install"
},
"keywords": [
Expand All @@ -30,20 +32,24 @@
"coverage",
".nyc_output",
"sample",
"sample/node_modules"
"sample/node_modules",
"test"
],
"check-coverage": true,
"lines": 85,
"statements": 80,
"statements": 85,
"functions": 80,
"branches": 56,
"branches": 75,
"reporter": [
"lcov",
"text-summary"
"text",
"text-summary",
"html",
"json"
]
},
"engines": {
"node": ">=6.0.0"
"node": ">=7.0.0"
},
"repository": {
"type": "git",
Expand All @@ -70,11 +76,13 @@
"popsicle": "10.0.1",
"query-string": "6.2.0",
"rsa-pem-from-mod-exp": "^0.8.4",
"winston": "^3.1.0"
"winston": "^3.1.0",
"coveralls": "3.0.2"
},
"devDependencies": {
"body-parser": "^1.15.2",
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
"chance": "^1.0.13",
"cors": "^2.8.1",
"coveralls": "^3.0.6",
Expand All @@ -88,6 +96,7 @@
"nyc": "^11.6.0",
"phantomjs-prebuilt": "^2.1.4",
"standard": "^11.0.0",
"sinon": "^7.5.0",
"watchify": "^3.7.0"
}
}
2 changes: 1 addition & 1 deletion sample/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This is a `sample` app built using Node.js and Express Framework to showcase how

### Requirements

* [Node.js](http://nodejs.org) >= 6.0.0
* [Node.js](http://nodejs.org) >= 7.0.0
* [Intuit Developer](https://developer.intuit.com) Account

### Via Github Repo (Recommended)
Expand Down
26 changes: 12 additions & 14 deletions sample/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,19 +163,17 @@ if(!ngrok){
if (ngrok) {

console.log("NGROK Enabled");
ngrok.connect({addr: process.env.PORT || 8000}, (err, url) => {
if (err) {
process.exit(1);
}
else {
redirectUri = url + '/callback';
console.log(`💳 Step 1 : Paste this URL in your browser : ${url}`);
console.log('💳 Step 2 : Copy and Paste the clientId and clientSecret from : https://developer.intuit.com')
console.log(`💳 Step 3 : Copy Paste this callback URL into redirectURI : ${redirectUri}`);
console.log(`💻 Step 4 : Make Sure this redirect URI is also listed under the Redirect URIs on your app in : https://developer.intuit.com`);

}
}
);
ngrok.connect({addr: process.env.PORT || 8000})
.then(url => {
redirectUri = url + '/callback';
console.log(`💳 Step 1 : Paste this URL in your browser : ${url}`);
console.log('💳 Step 2 : Copy and Paste the clientId and clientSecret from : https://developer.intuit.com')
console.log(`💳 Step 3 : Copy Paste this callback URL into redirectURI : ${redirectUri}`);
console.log(`💻 Step 4 : Make Sure this redirect URI is also listed under the Redirect URIs on your app in : https://developer.intuit.com`);

})
.catch(() => {
process.exit(1);
});
}

2 changes: 1 addition & 1 deletion sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"path": "^0.12.7",
"ejs": "^2.5.2",
"dotenv": "^5.0.1",
"ngrok": "^2.2.9",
"ngrok": "^3.2.5",
"intuit-oauth": "1.3.0"
}
}
Loading

0 comments on commit 4969620

Please sign in to comment.