Page 1 of 2
Can't login on Google
Posted: Wed Jan 26, 2022 4:49 pm
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
Re: Can't login on Google
Posted: Wed Jan 26, 2022 6:36 pm
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...
Re: Can't login on Google
Posted: Wed Jan 26, 2022 7:16 pm
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.
Re: Can't login on Google
Posted: Thu Jan 27, 2022 9:33 am
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.
Re: Can't login on Google
Posted: Thu Jan 27, 2022 11:43 am
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
But i set the user agent using GlobalCEFApp. Maybe the way you are doing works, could you please show some code sample ?
Re: Can't login on Google
Posted: Thu Jan 27, 2022 11:46 am
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
But unfortunatelly if there isn't other way, i'll have to follow this OAuth path.
Re: Can't login on Google
Posted: Thu Jan 27, 2022 4:37 pm
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
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.
Re: Can't login on Google
Posted: Fri Jan 28, 2022 12:07 pm
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...
Re: Can't login on Google
Posted: Fri Jan 28, 2022 1:27 pm
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
Re: Can't login on Google
Posted: Fri Jan 28, 2022 5:01 pm
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...