3.0.0 • Published 10 years ago

just-sdk v3.0.0

Weekly downloads
1
License
BSD 2-Clause
Repository
github
Last release
10 years ago

Just Connect SDK for JavaScript

Build Status

This is an SDK to talk to the Just Connect REST API from Node.js and web applications. It supports OAuth2 authorization with the Implicit, Authorization Code and Credentials grants.

Details on the API can be found here.

Prerequisites

To use this SDK, you need Node.js >= 0.12 or io.js. Node.js <= 0.10 is not compatible since it doesn't have some ES6-Features that the SDK uses.

Installing

Node.js

The preferred way to install the SDK is via the npm package manager. Type this into your terminal:

npm install just-sdk

Browser

For using the SDK in your web application, clone this repo, call npm install followed by grunt dist and copy the resulting file from the dist/ directory to your web server.

First Steps

The simplest way to try out this SDK is to fire it up in a Node.js application with the OAuth2 credentials grant, i.e. you authenticate with your username and password. Simply require the library, configure it with a domain, flow, username and password and then call its functions.

Here is a simple example:

var SDK = require('just-sdk');
var sdk = new SDK({
    domain: "just.loveyourintranet.com",
    oauth2: {
        flow: "credentials",
        username: "yourmail@example.org",
        password: "yourpassword",
        client_id: "your_client_id",
        client_secret: "your_client_secret"
    }
});
sdk.oauth2.token()
    .then(sdk.user.me.bind(sdk.user))
    .then(function(me) {
        console.log("You are using the API as " + me.name);
    })
    .catch(function(error) {
        console.log("There was an error fetching your profile information: " + error.message);
    })
    .done();

The examples directory holds more examples to get you started.

Configuration

The SDK is configured by passing a config object to the constructor:

KeyDescriptionType
domainThe Just domain you would like to talk to.string
oauth2An object containing the OAuth2-specific configuration. See below for details.object

For the different OAuth2 grant types, the oauth2 object holds different values:

Implicit Grant Flow

KeyDescriptionType
oauth2.flowSet this to implicit.string
oauth2.redirect_uriThe URI to redirect the user to after he has authenticated the application.string
oauth2.client_idThe client ID of your application.string

Credentials Grant Flow (Username/Password)

KeyDescriptionType
oauth2.flowSet this to credentials.string
oauth2.usernameThe username for authenticating towards Just.string
oauth2.passwordThe password for authenticating towards Just.string
oauth2.client_idThe client ID of your application.string
oauth2.client_secretThe client secret of your application.string

Authorization Code Grant Flow

KeyDescriptionType
oauth2.flowSet this to authorization_code.string
oauth2.client_idThe client ID of your application.string
oauth2.client_secretThe client secret of your application.string
oauth2.redirect_uriThe URI of your application that receives the authorization code.string

License

This SDK is distributed under the BSD 2-Clause License, see LICENSE for more information.

3.0.0

10 years ago

2.0.1

10 years ago

2.0.0

10 years ago

1.3.0

10 years ago

1.2.2

10 years ago

1.2.0

10 years ago

1.1.0

10 years ago

1.0.0

10 years ago

0.9.0

10 years ago

0.8.1

11 years ago

0.8.0

11 years ago

0.7.1

11 years ago

0.7.0

11 years ago

0.6.1

11 years ago

0.6.0

11 years ago

0.5.1

11 years ago

0.5.0

11 years ago

0.4.2

11 years ago

0.4.1

11 years ago

0.4.0

11 years ago

0.3.1

11 years ago

0.3.0

11 years ago

0.2.0

11 years ago

0.1.0

11 years ago