Google Sign-In API Hang with uncaught error Failed to get parent origin from URL hash

前端 未结 3 2009
攒了一身酷
攒了一身酷 2020-12-13 05:21

I\'m using Google Sign-In JavaScript client for months without problem. But recently when user tapping on sign in button from webapp that added to homescreen, the signin pop

3条回答
  •  鱼传尺愫
    2020-12-13 05:25

    My electron app started to fail today for the same reason. Been debugging quite a lot and I think found the reason, but don't know how to solve it, why it happened, or if it is electron or google's fault.

    In my electron app, I have 2 webviews, one for the main content and another one for google popup dialogs.

    So when google needs to open the authentication, it generates this IFRAME:

        
    

    Mind that the URL has HASH parameters: your origin and the token.

    However, when on the electron side I capture the new-window event in order to open the URL myself in another webview, the event I receive LACKS the hash parameters:

    event { 
      type : "new-window",
      url:"https://accounts.google.com/o/oauth2/iframe",
      .
      .
    }
    

    So what google's iframe is complaining about (I debugged it) is exactly that it can't find the origin and rpctoken parameters that should be in the hash parameters.

    For a reason I don't understand (I haven't updated electron) the new-window event does not receive the full url anymore.

    Using @howMuchCheeseIsTooMuchCheese answer below I have changed the flow to use the redirect callback, then capture that callback myself and restart the application. It is not ideal, but at least I can login into my applications.

提交回复
热议问题