This commit is contained in:
Tben 2023-08-08 12:28:34 +01:00
parent d4dafee552
commit 1aa46e4735
2 changed files with 6 additions and 3 deletions

View File

@ -11,10 +11,11 @@
* @param {string} params.clientId - Github app client ID: {@link https://datasquirel.com/docs} * @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 {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] - React setState Function: sets whether the google login button is ready or not
* *
* @returns {void} - Return * @returns {void} - Return
*/ */
module.exports = function getAccessToken({ clientId, redirectUrl, setLoading }) { module.exports = function getAccessToken({ clientId, redirectUrl, setLoading, scopes }) {
/** /**
* == Initialize * == Initialize
* *
@ -22,7 +23,9 @@ module.exports = function getAccessToken({ clientId, redirectUrl, setLoading })
*/ */
if (setLoading) setLoading(true); if (setLoading) setLoading(true);
const fetchUrl = `https://github.com/login/oauth/authorize?client_id=${clientId}&scope=user&redirect_uri=${redirectUrl}${window.location.pathname}`; 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}`;
window.location.assign(fetchUrl); window.location.assign(fetchUrl);
////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////

View File

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