Search code examples
javajavafxoauth-2.0google-oauth

Google authentication in Java fx webview


I'm developing an application that uses google oAuth2 authentication with google-api-client. In the webView, I open the url that the library gives me to access accessToken and try to authenticate. Everything is going well, to the step where you need to confirm the use of your account on your mobile device (https: //accounts.google.com/signin/challenge/az/2 ...). I click "Yes" on the device, but nothing happens in the webView. Although, if you try to do the same in the browser (using the url that the library gives out), then the redirect to the url with the code to get accessToken occurs.

Can someone encounter such a problem and know how to solve it?

P.S. I tried to debug the webView using the method described here "https://github.com/mohamnag/javafx_webview_debugger", but it did not help.


Solution

  • Well, I found the answer: it is a bug of this version.

    Cannot sign in to Google in JavaFX WebView

    To fix it you'll have to set cross-orign property:

    System.setProperty("sun.net.http.allowRestrictedHeaders", "true");