4

Easy question, not sure if there is a solution for this problem. I made a simple browser with WebView2 in a WPF C# app (I made this to be able to use a shell app while I browse on the url where the webview is). It use the same useragent as edge-chromium and until some months ago I was able to log in to google like in a regular browser. Now if I try to log in I get a "Not supported browser" error from google. Of course nothing changed in my application, but google say that it will not support log in from a webview ("browser that: Are embedded in a different application"):

https://support.google.com/accounts/answer/7675428?hl=en-GB

I don't really know if there is any workaround for this. I know that I was logged yesterday (and I think that it was possible thanks to the cache or something like that) so if there is a workaround to log in I should be able to stay log in. I know they suggest to use the google API: https://developers.google.com/identity/protocols/oauth2/native-app

And I already used that in a Unity3d game to log in to my google drive. But I'm not sure how to set my WebView2 to be logged in when I call that API (I know that I can use the response to make new API call and, for example, upload a file to my google drive, but I don't know how to set my webview to be logged and be able to go to google drive url and be logged in any google app).

My question is if you know how to solve this problem or if you got any idea on how to solve it. Or do you think that's not possible at all?

EDIT. just find out this is a problem with any webview. like you can see here github.com/MicrosoftEdge/WebView2Feedback/issues/1647 it's a security bullshit of google that, instead of finding a solution, blocked every webview out ther from log in to their services (they could solve the man in the middle problem in many ways like asking for a password app, ask for a more limited webview sandbox window etc... they just blocked everything).

So there is not really any solution for this. Even by using Oauth API you can only log in and wait for the response but you cannot access google like in a regular browser with that, you can only make more API call... that's not what I need. The only solution that I can think of is to just wait for microsoft or someone else to make a "sandbox environment" that will activate by default in a log in page of google (and that google will allow to log in), and will revert back to the regular webview once it is logged in.

LiefLayer
  • 977
  • 1
  • 12
  • 29
  • You could use something like `GeckoView` or `CefSharp`. – Trevor Sep 07 '21 at 13:17
  • @zaggler I think WebView2 is already a CefSharp implementation, but I'm not 100% sure. What I'm sure is that I already tried to implement CefSharp and I was only able to get the basic implementation done... There was not enough docs to get cookies and other feature that I need to use in my app. Also since google blocked the log in from embedded browser I think using GeckoView or CefSharp could be only a temporary workaround (not sure if they really works). I also know many webview are not able to play fullscreen html5 videos from youtube so I would like to avoid to change the webview. – LiefLayer Sep 07 '21 at 13:33
  • 1
    @zaggler just find out this is a problem with any webview. like you can see here https://github.com/MicrosoftEdge/WebView2Feedback/issues/1647 it's a security bullshit of google that, instead of finding a solution, blocked every webview out ther from log in to their services (they could solve the man in the middle problem in many ways like asking for a password app, ask for a more limited webview sandbox window etc... they just blocked everything). – LiefLayer Sep 07 '21 at 18:30
  • @LiefLayer WebView2 isn't CEFSharp. Instead it's based on Microsoft's Chromium-based Edge -- their own deployment of the same code that's behind almost all of Google Chrome. – O. Jones Sep 16 '21 at 11:19
  • @O.Jones Ok but that does not change the problem. You can see on that link (from github) that many people used CEFSharp and switched to WebView2 because of this problem. – LiefLayer Sep 16 '21 at 18:14
  • a year later ... any solution in the meantime? – Kux Sep 06 '22 at 01:06
  • @kux the only solution that I got was to change the user agent to any string (just do not use a real user agent, you can even use a "stupid" user agent), do that only on the log in page if you want... after the log in you can go back to the original user agent (just store it in a variable). – LiefLayer Sep 12 '22 at 13:18
  • PS. I think that's a bug on google side, but it was like that for a year so maybe it's just a workaround that you can use. – LiefLayer Sep 12 '22 at 13:19

0 Answers0