Last active
January 27, 2022 15:18
-
-
Save adamjmcgrath/4d3c7d4020db79a5b4dc5d2b81ffe1a2 to your computer and use it in GitHub Desktop.
Revisions
-
adamjmcgrath renamed this gist
Jan 27, 2022 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
adamjmcgrath created this gist
Jan 27, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ (() => { const DOMAIN_URL = 'https://brucke.auth0.com'; const CLIENT_ID = 'wLSIP47wM39wKdDmOj6Zb5eSEw3JVhVp'; const iframe = window.document.createElement('iframe'); iframe.setAttribute('width', '0'); iframe.setAttribute('height', '0'); iframe.style.display = 'none'; window.addEventListener( 'message', async e => { if (e.origin !== DOMAIN_URL) return; let response = e.data.response; if (response.code) { const tokens = await fetch(`${DOMAIN_URL}/oauth/token`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ client_id: CLIENT_ID, code: response.code, grant_type: 'authorization_code', redirect_uri: window.location.origin }) }); response = await tokens.json(); } alert(JSON.stringify(response, null, 2)); }, false ); window.document.body.appendChild(iframe); iframe.setAttribute( 'src', `${DOMAIN_URL}/authorize?client_id=${CLIENT_ID}&redirect_uri=${window.location.origin}&scope=openid%20profile%20email&response_type=code&response_mode=web_message&nonce=abc123&prompt=none` ); })();