Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

Can't login on Google

thefunkyjoint
Posts: 513
Joined: Thu Aug 10, 2017 12:40 pm

Can't login on Google

Post by thefunkyjoint »

Hello,

It's becoming more and more often when we try to login in any Google product using CEF4Delphi, an error message appears :

"Couldn’t sign you in This browser or app may not be secure."

As shown on the image below :
https://ibb.co/DQXKvz4

Looks like the authentication should be made using the OAuth protocol. Is there any examples about how to use it with CEF4Delphi ?

Thanks
thefunkyjoint
Posts: 513
Joined: Thu Aug 10, 2017 12:40 pm

Re: Can't login on Google

Post by thefunkyjoint »

Or even better, is there any workaround to avoid this error ?

Because even using OAuth would be a hassle as we need to submit informaiton to Google review and approve, have a page with details about app, a lot of burocracy...
User avatar
salvadordf
Posts: 4580
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Can't login on Google

Post by salvadordf »

Sadly, I don't have any new information about this.

Last time I checked it was possible to login using the new "Chrome runtime" mode but it's still in experimental state and that mode hasn't improved in the last months.

The code in the OAuth2Tester demo should be enough to authenticate using OAuth2 but I haven't tried to use the access token recently.

This is a real problem for CEF developers but also for WebView2 developers. Google is blocking everyone.
Student
Posts: 73
Joined: Tue Aug 07, 2018 9:20 am

Re: Can't login on Google

Post by Student »

To solve this problem, replace the useragent with any other non chromium, I usually replace it during the request for accounts.google.com and immediately there is no mistake with security.
thefunkyjoint
Posts: 513
Joined: Thu Aug 10, 2017 12:40 pm

Re: Can't login on Google

Post by thefunkyjoint »

Student wrote: Thu Jan 27, 2022 9:33 am To solve this problem, replace the useragent with any other non chromium, I usually replace it during the request for accounts.google.com and immediately there is no mistake with security.
This is what i've been doing for the last year. First i used a Firefox user agent , worked, but then after a while, blocked. Then i switch to Safari, worked and after a while, blocked too. Tried other user agents, but no lucky.

There are SOME logins that will work, but it's getting more and more often that a lot of logins are being blocked :cry:

But i set the user agent using GlobalCEFApp. Maybe the way you are doing works, could you please show some code sample ?
thefunkyjoint
Posts: 513
Joined: Thu Aug 10, 2017 12:40 pm

Re: Can't login on Google

Post by thefunkyjoint »

salvadordf wrote: Wed Jan 26, 2022 7:16 pm Sadly, I don't have any new information about this.

Last time I checked it was possible to login using the new "Chrome runtime" mode but it's still in experimental state and that mode hasn't improved in the last months.

The code in the OAuth2Tester demo should be enough to authenticate using OAuth2 but I haven't tried to use the access token recently.

This is a real problem for CEF developers but also for WebView2 developers. Google is blocking everyone.
I'm trying to avoid using OAuth because it's a hassle... and of course, once they know the user is logging using your app, of course they will monitore your app's activity and even over time they will try to charge the app creator in some way. A web browser should be free and private :roll:

But unfortunatelly if there isn't other way, i'll have to follow this OAuth path.
Student
Posts: 73
Joined: Tue Aug 07, 2018 9:20 am

Re: Can't login on Google

Post by Student »

thefunkyjoint wrote: Thu Jan 27, 2022 11:43 am
Student wrote: Thu Jan 27, 2022 9:33 am To solve this problem, replace the useragent with any other non chromium, I usually replace it during the request for accounts.google.com and immediately there is no mistake with security.
This is what i've been doing for the last year. First i used a Firefox user agent , worked, but then after a while, blocked. Then i switch to Safari, worked and after a while, blocked too. Tried other user agents, but no lucky.

There are SOME logins that will work, but it's getting more and more often that a lot of logins are being blocked :cry:

But i set the user agent using GlobalCEFApp. Maybe the way you are doing works, could you please show some code sample ?
in BeforeResourceLoad add checking code

Code: Select all

  var oldHeader, newHeader: ICefStringMultimap;
  i:integer;
  
  if pos('https://accounts.google.com', request.URL) = 1
  then
  begin
    oldHeader := TCefStringMultimapOwn.Create;
    newHeader := TCefStringMultimapOwn.Create;
    request.GetHeaderMap(oldHeader);
    for i := 0 to oldHeader.size - 1 do
    begin
      if oldHeader.Key[i] = 'User-Agent' then
        newHeader.append('User-Agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:95.0) Gecko/20100101 RandomString/95.0')
      else
        newHeader.append(oldHeader.Key[i], oldHeader.Value[i]);
    end;
    request.SetHeaderMap(newHeader);
    oldHeader := nil;
    newHeader := nil;
  end;

sometimes it gives an error about the insecurity of the browser, I press the back button and repeat the login and the security check passes.
thefunkyjoint
Posts: 513
Joined: Thu Aug 10, 2017 12:40 pm

Re: Can't login on Google

Post by thefunkyjoint »

Thanks , will try that.

But one thing i already noticed with this procedure is, sometimes it won't work and the site will respect the useragent defined on GlobalCefApp. For instance, if you leave GlobalCefApp.userAgent blank, but send an Iphone Safari's user agent on this method, google.com will not show the mobile version instead of desktop. Don't know really why this happens...
Student
Posts: 73
Joined: Tue Aug 07, 2018 9:20 am

Re: Can't login on Google

Post by Student »

thefunkyjoint wrote: Fri Jan 28, 2022 12:07 pm Thanks , will try that.

But one thing i already noticed with this procedure is, sometimes it won't work and the site will respect the useragent defined on GlobalCefApp. For instance, if you leave GlobalCefApp.userAgent blank, but send an Iphone Safari's user agent on this method, google.com will not show the mobile version instead of desktop. Don't know really why this happens...
To control the display of the site, you may need to pass additional headers, for example, set under the mobile screen like this
Sec-CH-UA-Mobile: ?1
thefunkyjoint
Posts: 513
Joined: Thu Aug 10, 2017 12:40 pm

Re: Can't login on Google

Post by thefunkyjoint »

One thing i did not understand : if you are already setting the username in GlobalCefApp, why would you have to put it again on BeforeResourceLoad ? This doesn't make sense...
Post Reply