From a5ac3d26f3fa47577bb9eb7e279097ac23321007 Mon Sep 17 00:00:00 2001 From: Ken Eucker Date: Mon, 8 Mar 2021 23:29:07 -0800 Subject: [PATCH] feat(setaccesstoken): adding a new method setAccessToken to set the access token externally This feature will allow users to authenticate outside of the imgur package. --- lib/imgur.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/imgur.js b/lib/imgur.js index 193d54cc..50fbab12 100644 --- a/lib/imgur.js +++ b/lib/imgur.js @@ -184,6 +184,17 @@ imgur._getAuthorizationHeader = async () => { return `Bearer ${imgurAccessToken}`; }; +/** + * Set your Authorization if authenticating separately + * @link https://api.imgur.com/#register + * @param {string} accessToken + */ +imgur.setAccessToken = function (accessToken) { + if (accessToken && typeof accessToken === 'string') { + imgurAccessToken = accessToken; + } +}; + /** * Set your credentials * @link https://api.imgur.com/#register