Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion lib/goodreads-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ var Goodreads = function Goodreads(credentials, callbackURL) {
* @returns {undefined}
*/
function initOAuth(callbackURL) {
if (!callbackURL) logWarning('Warning: You have passed no callbackURL.', 'initOauth()');
if (!callbackURL) logWarning('Warning: You have passed no callbackURL.', 'initOAuth()');

var requestURL = URL + '/oauth/request_token';
var accessURL = URL + '/oauth/access_token';
Expand Down Expand Up @@ -166,6 +166,39 @@ var Goodreads = function Goodreads(credentials, callbackURL) {
});
};

/**
* setAccessToken - call this if you have a key-pair saved from a previous
* session.
*
* @access public
*/
function setAccessToken(_ref) {
var token = _ref.token,
secret = _ref.secret;

_setAccessToken({
ACCESS_TOKEN: token,
ACCESS_TOKEN_SECRET: secret
});
OAUTHENTICATED = true;
}

/**
* dumpAccessToken - call this to get ahold of the key-pair to save it
* for future sessions.
*
* @access public
*/
function dumpAccessToken(_ref2) {
var token = _ref2.token,
secret = _ref2.secret;

return {
token: ACCESS_TOKEN,
secret: ACCESS_TOKEN_SECRET
};
}

/**
* followAuthor
*
Expand Down Expand Up @@ -959,6 +992,8 @@ var Goodreads = function Goodreads(credentials, callbackURL) {
initOAuth: initOAuth,
getRequestToken: getRequestToken,
getAccessToken: getAccessToken,
setAccessToken: setAccessToken,
dumpAccessToken: dumpAccessToken,
_setOAuthToken: _setOAuthToken,
getBooksByAuthor: getBooksByAuthor,
getAuthorInfo: getAuthorInfo,
Expand Down
29 changes: 29 additions & 0 deletions src/goodreads-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,33 @@ const Goodreads = function(credentials, callbackURL) {
});
};

/**
* setAccessToken - call this if you have a key-pair saved from a previous
* session.
*
* @access public
*/
function setAccessToken({token, secret}) {
_setAccessToken({
ACCESS_TOKEN: token,
ACCESS_TOKEN_SECRET: secret
});
OAUTHENTICATED = true;
}

/**
* dumpAccessToken - call this to get ahold of the key-pair to save it
* for future sessions.
*
* @access public
*/
function dumpAccessToken({ token, secret }) {
return {
token: ACCESS_TOKEN,
secret: ACCESS_TOKEN_SECRET
};
}

/**
* followAuthor
*
Expand Down Expand Up @@ -1083,6 +1110,8 @@ const Goodreads = function(credentials, callbackURL) {
initOAuth,
getRequestToken,
getAccessToken,
setAccessToken,
dumpAccessToken,
_setOAuthToken,
getBooksByAuthor,
getAuthorInfo,
Expand Down