- 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
authmethod if the access token is expired.