@followprice/api-client v2.0.6
API client
Requirements
It should authenticate a user through an OAuth2 password grant type and receive an
access_token.Store the
access_tokeninternally.It should let that user request data to API endpoints with that
access_token.
How to develop?
Install git-flow
Code according to it
Commit bug fixes to the development branch
git flow feature start <name>to start a new feature
Run the project
npm start- code changes will be automatically reloaded on the browser
Authenticate
on your browser console
var API = require('followprice-api-client'); var api = new API('scope', 'hostname', 'port'); // only if using a private client api.setClient('client_id', 'client_secret'); api.authenticate('user', 'password', err => { if (err) { /* handle error */ } // you're authenticated here })client_idshould be the client's id- e.g. test
client_secretshould be the client's secretit has no authentication value, as the client runs on the user-agent and is, as such, public
e.g. test
scopeshould be scope the user wants to requesthostnameis optional, as it defaults toapi.followprice.coportis optional, as it defaults to443usershould be the user'susernamepasswordshould the user'spassword
Make API calls
on your browser console
// your callback should follow the format (err, statusCode, data) => { ... } api.get('/users', null, callback);