Skip to content

mingliangguo/rest-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

README

A simple but powerful Rest API Client that can be used to talk with different REST service providers by simple extension.

The framework comes with two examples for box.com and google.com. So it should be quite straightforward to follow and create REST client for other service providers.

Quick start

For box, assume you have your own box application that can be used to talk with box service. Add your app information to config.ini.

BOX_CLIENT_ID=your_box_app_client_id
BOX_CLIENT_SECRET=your_box_app_client_secret
BOX_TOKEN_JSON_FILE=examples/box/box-tokens.json

Once you have the app information configured, start with the oauth process:

npm run box -- --action=oauth

It should launch a browser window to ask you authorize the app, and after the authorization is done, make sure you have redirect url configured for your app, to receive the authorization code. Copy the code, and use it in the following command:

npm run box -- --action=token --code=your_oauth_code

Once the token action completes, it saves the token in the token file (configured in config.ini).

There are some pre-configured actions in the sample implementation, and it should be pretty straightforward to add other actions for your own need.

Note, you can do the same for google rest services.

npm run google -- --action=oauth
npm run google -- --action=token --code=your_oauth_code

Logging output

The Rest Client uses winston as the logging framework, and use LOG_LEVEL environment variable to control the logout. For example:

LOG_LEVEL=debug npm run box -- --action=user --uid=me

FAQ

Convert pkcs key file to pem key

Sometime you might only have a pkcs key file, but need to convert to pem for use in node. Using the following command to get it done:

openssl pkcs12 -in my-privatekey.p12 -out privatekey.pem -nodes

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published