Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not getting response from provder.perform(window) (Possible update) #69

Open
dennington-bear opened this issue Apr 26, 2019 · 2 comments

Comments

@dennington-bear
Copy link

Hey so Ive been trying to implement your plugin but I had to hack about to get it to work.
Im using ionic's capacitor to generate electron and using Angular 7 as my framework.
The electron version is:

"electron": "^4.1.4",
"electron-oauth-helper": "^3.0.0",
 "firebase": "5.6.0"

Using your docs I tried implementing everything as you have described in the docs and got no response from the new window.

const provider = new OAuth2Provider(mapTypeToConfig('GoogleClientWebApp'));

    const options = Object.assign({
        show: false,
        width: 800,
        height: 800,
        webPreferences: {
            nodeIntegration: false,
            contextIsolation: true,
        },
    })

    let window = new BrowserWindow(options);
    window.once("ready-to-show", () => {
        window.show()
    })
    window.once("closed", () => {
            window = null
        })
provider.perform(window).then(resp => {
      // window.close()
      console.log("Got response (◍•ᴗ•◍):", resp)// <-- Never gets to here
}).catch(error => console.error(error))

I had a dig through the code and discovered in redirect.js this line never finished executing

webContents.session.webRequest.onBeforeRedirect({ urls: [redirectURL] },
            detail => {
                // Never got to here
                debug("will redirect", detail.redirectURL)
                if (isRedirectURL(detail.redirectURL)) {
                    resolve(detail.redirectURL)
                }
            }
        )

But by altering the code to use a string instead of an array fixes it. Ive no idea why it just works after. It could be a possible update to electrn under the hood?

webContents.session.webRequest.onBeforeRedirect({ urls: redirectURL },
            detail => {
                debug("will redirect", detail.redirectURL)
                if (isRedirectURL(detail.redirectURL)) {
                    resolve(detail.redirectURL)
                }
            }
        )

I thought this might be helpful incase anyone comes accross this too

@dennington-bear dennington-bear changed the title Not getting response from provder.perform(window) Not getting response from provder.perform(window) (Possible update) Apr 26, 2019
@mironal
Copy link
Owner

mironal commented Apr 29, 2019

Thanks for reporting. I'll look into it.

@christian-judt
Copy link

Basically the same problem appears in my environment:
"electron": "4.0.8", "electron-oauth-helper": "3.0.0",

The relevant redirect is not detected and no response is provided.

Also both the fix described above and entirely removing the argument
{ urls: [redirectURL] }, restored the redirection detection and thereby resolved the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants