2.0.6 • Published 7 years ago

@followprice/api-client v2.0.6

Weekly downloads
-
License
ISC
Repository
github
Last release
7 years ago

API client

Requirements

  1. It should authenticate a user through an OAuth2 password grant type and receive an access_token.

  2. Store the access_token internally.

  3. It should let that user request data to API endpoints with that access_token.

How to develop?

  1. Install git-flow

  2. Code according to it

    • Commit bug fixes to the development branch

    • git flow feature start <name> to start a new feature

Run the project

  1. 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 to api.followprice.co

    • port is optional, as it defaults to 443

    • user should be the user's username

    • password should the user's password

Make API calls

  • on your browser console

    // your callback should follow the format (err, statusCode, data) => { ... }
    api.get('/users', null, callback);