0.1.5 • Published 12 years ago

sellmate-utils v0.1.5

Weekly downloads
19
License
-
Repository
github
Last release
12 years ago

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:*

    ```javascript
    oa.getAccessToken(code, {
    	'shop': 'my-shop',
    	'grant_type': 'authorization_code',
    }, function(error, response, body) {
    	// 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
0.1.5

12 years ago

0.1.4

12 years ago

0.1.3

12 years ago

0.1.2

12 years ago