sellmate-utils

Help libs to authenticate against the Sellmate REST API

sellmate-utils

Useful authentication module to help you connect your App with the Sellmate REST API www.sellmate.com.

Installation

$ npm install sellmate-utils

or

$ git clone git://github.com/emmenko/sellmate-utils.git
$ cd sellmate-utils
$ npm install

Quick start

  1. Create a new OAuth2 object with some parameters (host is optional, default is 'auth.sellmate.com'):

    var oa = new OAuth2(client_id, client_secret, redirectUri, host);
     
    e.g.: var oa = new OAuth2('1234', 'qwertasdfgzxcv', 'http://localhost:8888/callback');
  2. Get the OAuth Request Token URL and call it (parameters are optional, i.e. shop):

    var authUrl = oa.getAuthorizeUrl(params);
     
    e.g.: var authUrl = oa.getAuthorizeUrl({ 'shop': 'my-shop' });
  3. Your App should have a callback servlet (i.e. http://localhost:8888/callback) where you get the notification with the code as a parameter. Now you can request an AccessToken:

    oa.getAccessToken(code, {
        'shop': 'my-shop',
        'grant_type': 'authorization_code',
    }, function(errorresponsebody) {
        // The body response contains some parameters among which you will  
        // find the `access_token` and the `refresh_token` 
    });

Example

There is an example app at ./example

$ node examples/server.js
$ open http://localhost:8888

Testing

$ npm test