Skip to content

Instantly share code, notes, and snippets.

@foutrelis
Last active October 26, 2024 03:52
Show Gist options
  • Save foutrelis/14e339596b89813aa9c37fd1b4e5d9d5 to your computer and use it in GitHub Desktop.
Save foutrelis/14e339596b89813aa9c37fd1b4e5d9d5 to your computer and use it in GitHub Desktop.
===================================================================
Google doesn't allow using Chrome's API keys in Chromium builds and
strongly recommends against doing so. These OAuth 2 credentials are
taken from publicly available sources, but their fitness for use in
Chromium builds is not warrantied.
===================================================================
!!! Use these keys to reactivate Sync in Chromium at your own risk;
they are extremely likely to stop working in the (near) future.
$ grep oauth2 ~/.config/chromium-flags.conf
--oauth2-client-id=77185425430.apps.googleusercontent.com
--oauth2-client-secret=OTJgUOQcT7lO7GsGZq2G4IlT
Note: The above works on Arch Linux because of its custom launcher,
plus a patch to reuse --oauth2-client-{id,secret} for setting
GOOGLE_DEFAULT_CLIENT_{ID,SECRET} similar to environment vars.
https://wiki.archlinux.org/index.php/Chromium#Making_flags_persistent
@compwiztobe
Copy link

The command is just grep oauth2 ~/.config/chromium-flags.conf showing that the following two lines should appear in ~/.config/chromium-flags.conf (after you add them of course). The alternative is passing the values with environment variables (GOOGLE_API_KEY can only be passed as an environment variable, there is no flag), or building them into the binary if you compile from source.

@bquast
Copy link

bquast commented Mar 11, 2021

Thanks, sorry yes I should have been able to figure that out. Created the file and added the lines. It works great!

Unrelated, but is there a good way to make the opening of docx etc. work. For me it works on Chrome, but not chromium

@DAC324
Copy link

DAC324 commented Apr 29, 2021

Hello all,

thank you very much for this discussion. However, it looks like I am still missing something.
I created API keys and all credentials according to the guide on

https://www.chromium.org/developers/how-tos/api-keys

And then launched chromium with these environment variables to re-enable the APIs (log back into Sync, etc.) with:

export GOOGLE_API_KEY=...
export GOOGLE_DEFAULT_CLIENT_ID=...
export GOOGLE_DEFAULT_CLIENT_SECRET=...
chromium

Unfortunately, I am still unable to log in to my Google account from within Chromium-Dev (92.0.4484.7). After entering my Google username, I only get the message "This browser or app may not be secure. Try using a different browser."

What do I have to do in addition in order to enable my newly created credentials in Chromium-Dev?

OK, looks like the browser's user agent has to be changed to something more convenient to Google (example: Chrome on Windows):
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36

@KhashayarDanesh
Copy link

Hello All,

I'm doing the setup on a mac, and global imports don't work on mac as they should on a normal unix system, so I thought I could prevent some headaches:

/etc/default or ~/.profile variable imports are not passed to applications ran with spotlight or aqua/finder, so you should pass the variables to launchd to be able to inherit variables within applications ran with aqua/finder/spotlight.

You have multiple ways of setting global variables using launchd:

  1. Setting environment variables using a launchd unit : see the link

  2. You can add global variables to launchd within your shell's .profile or /etc/default with adding the following lines:

GOOGLE_API_KEY=""
GOOGLE_DEFAULT_CLIENT_ID="client_id_you_saw_under_oauth"
GOOGLE_DEFAULT_CLIENT_SECRET="client_secret_you_saw_under_oauth"

launchctl setenv GOOGLE_API_KEY $GOOGLE_API_KEY
launchctl setenv GOOGLE_DEFAULT_CLIENT_ID $GOOGLE_DEFAULT_CLIENT_ID
launchctl setenv GOOGLE_DEFAULT_CLIENT_SECRET $GOOGLE_DEFAULT_CLIENT_SECRET

@Magma5
Copy link

Magma5 commented Apr 4, 2024

Add these into the LSEnvironment section in Chromium.app/Contents/Info.plist before launching for the first time:

	<key>LSEnvironment</key>
	<dict>
		<key>MallocNanoZone</key>
		<string>0</string>
		<key>GOOGLE_DEFAULT_CLIENT_ID</key>
		<string>...</string>
		<key>GOOGLE_DEFAULT_CLIENT_SECRET</key>
		<string>...</string>
		<key>GOOGLE_API_KEY</key>
		<string></string>
	</dict>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment