0.1.5 • Published 12 years ago
sellmate-utils v0.1.5
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
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');
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' });
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