2.1.1 • Published 6 years ago

adp-connection v2.1.1

Weekly downloads
263
License
Apache-2.0
Repository
github
Last release
6 years ago

ADP Connection Library

Description

The ADP Connection library wraps the authorization (oAuth 2.0) connection steps for connecting to ADPs API gateway.

npm version

Previous version support

npm install adp-connection@1.1.1

Installation

$ npm install adp-connection

Usage

API Docs & Examples

Create Client Credentials ADP Connection

import adpConnection from 'adp-connection';

const connectionOpts = {
    clientId: '1234567890',
    clientSecret: 'ABC-DEF-GHI-JKL',
    granttype: 'client_credentials',
    sslCertPath: './certs/cert.pem',
    sslKeyPath: './certs/cert.key'
};
const connectionComplete = err => {
    // Use adp-core to do all the things...
};
const conn = adpConnection.createConnection(connectionOpts);
conn.connect(connectionComplete);

Create Authorization Code ADP Connection

import adpConnection from 'adp-connection';

const connectionOpts = {
    clientId: '1234567890',
    clientSecret: 'ABC-DEF-GHI-JKL',
    granttype: 'authorization_code',
    sslCertPath: './certs/cert.pem',
    sslKeyPath: './certs/cert.key',
    callbackUrl: 'https://myapp.domain.com/callback'
};
const conn = adpConnection.createConnection(connectionOpts);

// in an express app...
res.redirect(conn.getAuthorizationRequest());

// Authorization endpoint will respond to `https://myapp.domain.com/callback` with `code` query parameter
const authorizationCode = req.query.code;

// Set authorizationCode in connection options. 
connectionOpts.authorizationCode = authorizationCode;

// createConnection with authorizationCode set.
const conn = adpConnection.createConnection(connectionOpts);
const connectionComplete = err => {
    // connected ...
};
conn.connect(connectionComplete);

Debug

Enable debugging by setting the NODE_DEBUG environment variable.

$ export NODE_DEBUG=adp-connection,adp-core

Contributing

To contribute to the library, please generate a pull request. Before generating the pull request, please insure the following: 1. Appropriate unit tests have been updated or created. 2. Code coverage on unit tests must be no less than 100%. 3. Your code updates have been fully tested and linted with no errors. 4. Update README and API documentation as appropriate.

Sample Client

A sample client is provided to demonstrate usage of the libraries. The sample client connects to a sandbox environment hosted by ADP, and comes preconfigured with the necessary credentials and certificates to connect to the sandbox server.

Authorization Code Example

$ git clone https://github.com/adplabs/adp-connection-node.git
$ cd adp-connection-node
$ npm install
$ node authorizationCodeExample

Client Credentials Example

$ git clone https://github.com/adplabs/adp-connection-node.git
$ cd adp-connection-node
$ npm install
$ node clientCredentialsExample

Test Execution

$ npm test

Code Coverage

$ npm run coverage

Lint

$ npm run lint

License

Apache 2

2.1.1

6 years ago

2.1.0

6 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.11

8 years ago

1.0.10

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago