This commit is contained in:
Tben 2023-08-08 15:27:45 +01:00
parent 2208fcfd5b
commit 1f9990f80e
2 changed files with 3 additions and 15 deletions

View File

@ -12,11 +12,10 @@
* @param {string} params.redirectUrl - Github Redirect URL as listed in your oauth app settings: {@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 {function(boolean): void} [params.setLoading] - 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 {string[]} [params.scopes] - Scopes to be requested from the user
* @param {{key: string, value: string}[] | string} [params.extraUriParams] - Extra params to be added to the url
* *
* @returns {void} - Return * @returns {void} - Return
*/ */
module.exports = function getAccessToken({ clientId, redirectUrl, setLoading, scopes, extraUriParams }) { module.exports = function getAccessToken({ clientId, redirectUrl, setLoading, scopes }) {
/** /**
* == Initialize * == Initialize
* *
@ -25,18 +24,7 @@ module.exports = function getAccessToken({ clientId, redirectUrl, setLoading, sc
if (setLoading) setLoading(true); if (setLoading) setLoading(true);
const scopeString = scopes ? scopes.join("%20") : "read:user"; const scopeString = scopes ? scopes.join("%20") : "read:user";
const fetchUrl = `https://github.com/login/oauth/authorize?client_id=${clientId}&scope=${scopeString}&redirect_uri=${redirectUrl}`;
const extraUriParamsString = extraUriParams
? typeof extraUriParams == "string"
? extraUriParams
: `?${Object.keys(extraUriParams)
.map((key) => `${key}=${extraUriParams[key]}`)
.join("&")}`
: "";
console.log("extraUriParamsString:", extraUriParamsString);
const fetchUrl = `https://github.com/login/oauth/authorize?client_id=${clientId}&scope=${scopeString}&redirect_uri=${redirectUrl}${extraUriParamsString}`;
window.location.assign(fetchUrl); window.location.assign(fetchUrl);
////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,6 @@
{ {
"name": "datasquirel", "name": "datasquirel",
"version": "1.3.7", "version": "1.3.8",
"description": "Cloud-based SQL data management tool", "description": "Cloud-based SQL data management tool",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {