diff --git a/app/network/o-auth-2/grant-authorization-code.js b/app/network/o-auth-2/grant-authorization-code.js index 9a0243a02..2a0d08c35 100644 --- a/app/network/o-auth-2/grant-authorization-code.js +++ b/app/network/o-auth-2/grant-authorization-code.js @@ -57,10 +57,12 @@ async function _authorize (url, clientId, redirectUri = '', scope = '', state = // Add query params to URL const qs = querystring.buildFromParams(params); const finalUrl = querystring.joinUrl(url, qs); - const regex = new RegExp(`${escapeRegex(redirectUri)}.*(code=|error=)`); + const regex = new RegExp(`${escapeRegex(redirectUri)}.*(code=|error=)`, 'i'); const redirectedTo = await authorizeUserInWindow(finalUrl, regex); + console.log('[oauth2] Detected redirect ' + redirectedTo); + const {query} = urlParse(redirectedTo); return responseToObject(query, [ c.P_CODE, diff --git a/app/network/o-auth-2/misc.js b/app/network/o-auth-2/misc.js index 05ac8da1e..4cab44584 100644 --- a/app/network/o-auth-2/misc.js +++ b/app/network/o-auth-2/misc.js @@ -53,8 +53,11 @@ export function authorizeUserInWindow (url, urlRegex = /.*/) { child.webContents.on('did-navigate', () => { const url = child.webContents.getURL(); if (url.match(urlRegex)) { + console.log(`[oauth2] Matched redirect to "${url}" with ${urlRegex.toString()}`); finalUrl = url; child.close(); + } else { + console.log(`[oauth2] Ignoring redirect to "${url}" with match ${urlRegex.toString()}`); } });