Search code examples
youtubechromium-embedded

How to sign-in to Google Account with Chromium Embedded Framework (CEF)


Is there a way to sign-in to a Google / YouTube account with Chromium Embedded Framework (CEF)?

The Google sign-in page in CEF shows

Couldn't sign you in
This browser or app may not be secure.
Try using a different browser. If you’re already using a supported browser, you can try again to sign in.
  • What is the proper way to ask for Google authentication in CEF?
  • Is there a workaround to overcome this (I also accept ugly hacky stuff like copy session cookies)?

Motivation

The goal is to allow users to use their YouTube Premium features in CEF.

I have a game that uses CEF to integrate YouTube. It works well, but of course YouTube ads are annoying. I expected the YouTube login to work, such that people could use their YouTube Premium without ads from YouTube. Sadly, this does not work because people cannot login to their Google account and thus cannot access YouTube Premium.


Solution

  • Setting a User-Agent of a browser that is allowed by Google might work.

    For example, this works for me:

    setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0");
    

    Note however that Google may change the list of allowed browsers anytime. So, this is only a workaround.