Skip to content

Releases: oauth-io/sdk-node

Version 0.2.0

10 Jun 16:49
Compare
Choose a tag to compare
  • New, more polyvalent auth method
  • Token renewal support when available

The 0.2.0 changes a bit the syntax to perform the authentication and to retrieve a request_object to make API requests.

Authenticating the user with a code

OAuth.auth('provider', req.session, {
    code: 'the_code_you_got_from_the_front_end'
})
    .done(function (request_object) { /* make requests here */ })
    .fail();

This saves also the credentials in the session for the duration of the user's visit.

Authenticating the user from the session

OAuth.auth('provider', req.session)
    .done(function (request_object) { /* make requests here */ })
    .fail();

Authenticating the user from saved credentials

You can save a user's credentials (what's returned by OAuth.io, an object containing the access_token, refresh_token, etc) in the data storage of your choice. To retrieve the credentials, do this:

var credentials = request_object.getCredentials();

Later, you can use this object like this to rebuild a request_object:

OAuth.auth('provider', req.session, {
    credentials: credentials
})
    .done(function (request_object) { /* make requests here */ })
    .fail();

Note that the credentials are automatically refreshed through the auth method if the access token is expired.

Version 0.1.1

06 Jun 18:26
Compare
Choose a tag to compare
  • A few improvements in unit tests
  • Merged pull request from Bastian Kistner, adding .me() in callback of .auth() method

Version 0.1.0

09 May 12:40
Compare
Choose a tag to compare

This version of the SDK allows you to implement OAuth.io's server side flow on your Node.js backend. The following features are supported :

  • state token generation
  • access_token retrieval server-side
  • standard API requests .get|post|put|delete|patch(url) from the backend
  • unified me() request from the backend

To install the SDK, just run the following command in your Node.js project :

$ npm install oauthio --save