diff --git a/client/auth/github/getAccessToken.js b/client/auth/github/getAccessToken.js index ec73392..4bf0b50 100644 --- a/client/auth/github/getAccessToken.js +++ b/client/auth/github/getAccessToken.js @@ -11,11 +11,12 @@ * @param {string} params.clientId - Github app client ID: {@link https://datasquirel.com/docs} * @param {string} params.redirectUrl - Github Redirect URL as listed in your oauth app settings: {@link https://datasquirel.com/docs} * @param {function(boolean): void} [params.setLoading] - React setState Function: sets whether the google login button is ready or not - * @param {string[]} [params.scopes] - React setState Function: sets whether the google login button is ready or not + * @param {string[]} [params.scopes] - Scopes to be requested from the user + * @param {{key: string, value: string}[]} [params.extraParams] - Extra params to be added to the url * * @returns {void} - Return */ -module.exports = function getAccessToken({ clientId, redirectUrl, setLoading, scopes }) { +module.exports = function getAccessToken({ clientId, redirectUrl, setLoading, scopes, extraParams }) { /** * == Initialize * @@ -25,7 +26,13 @@ module.exports = function getAccessToken({ clientId, redirectUrl, setLoading, sc const scopeString = scopes ? scopes.join("%20") : "user"; - const fetchUrl = `https://github.com/login/oauth/authorize?client_id=${clientId}&scope=${scopeString}&redirect_uri=${redirectUrl}${window.location.pathname}`; + const extraParamsString = extraParams + ? `&${Object.keys(extraParams) + .map((key) => `${key}=${extraParams[key]}`) + .join("&")}` + : ""; + + const fetchUrl = `https://github.com/login/oauth/authorize?client_id=${clientId}&scope=${scopeString}&redirect_uri=${redirectUrl}${window.location.pathname}${extraParamsString}`; window.location.assign(fetchUrl); ////////////////////////////////////////////////////////////////////////////////// diff --git a/package.json b/package.json index 0bc42a4..b4967cb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "datasquirel", - "version": "1.3.3", + "version": "1.3.4", "description": "Cloud-based SQL data management tool", "main": "index.js", "scripts": {