I have an auth workflow that opens a window to an external URL. The URL redirects to another URL that returns a token. I need to retrieve that token in my application.
Right now I have the following code:
const url = await retrieveAuthURL()
console.log(`Redirecting to auth url ${url}`)
if (url === null) {
console.log('Received null auth url')
return
}
window.open(url, '_blank', 'location=yes,height=700,width=600,scrollbars=0,status=1')
window.addEventListener('message',handleEvent)
where handleEvent takes the event and mutates the state of the program to set the user info based on it. But the event doesn't fire - I am guessing because a redirect, differently from a fetch, doesn't count as an event?
How do I go about retrieving the auth information I need?