API client
Requirements
-
It should authenticate a user through an OAuth2 password grant type and receive an
access_token
. -
Store the
access_token
internally. -
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_id
should be the client's id- e.g. test
-
client_secret
should be the client's secret-
it has no authentication value, as the client runs on the user-agent and is, as such, public
-
e.g. test
-
-
scope
should be scope the user wants to request -
hostname
is optional, as it defaults toapi.followprice.co
-
port
is optional, as it defaults to443
-
user
should be the user'susername
-
password
should the user'spassword
-
Make API calls
-
on your browser console
// your callback should follow the format (err, statusCode, data) => { ... } api.get('/users', null, callback);