Skip to content

Instantly share code, notes, and snippets.

@cvan
Last active September 18, 2024 15:35
Show Gist options
  • Save cvan/44a6d60457b20133191bd7b104f9dcc4 to your computer and use it in GitHub Desktop.
Save cvan/44a6d60457b20133191bd7b104f9dcc4 to your computer and use it in GitHub Desktop.
Launch Chromium with API Keys on Mac OS X and Windows

Last Updated: March 2023

IMPORTANT: Ignore the out-of-date steps below for getting Chromium keys.

Instead, read this up-to-date guide (Jan 2023) written by @LearningToPi.

P.S. Thank you to every contributor below who provided tips over the years on what should be a straightforward process: setting up Chromium for local development.

Long live the web!


Sometimes you need to use API Keys to use things like the Speech API. And then you Google a bit and follow all the instructions. But the Chromium Project's API Keys page does a not-so-great of explaining how to do this, so I will.

  1. Download Chromium.
  2. You'll notice a yellow disclaimer message appear as a doorhanger: Google API Keys are missing. Some functionality of Chromium will be disabled. Learn More.
  3. Clicking on that link takes you to the confusing API Keys docs page.
  4. If you aren't already, subscribe to the chromium-dev@chromium.org mailing list. (You can just subscribe to the list and choose to not receive any mail. FYI: the Chromium project restricts the APIs to those subscribed to that group - that is, Chromium devs.)
  5. Make sure you are logged in with the Google account associated with the email address that you used to subscribe to chromium-dev.
  6. Log in to the Google Cloud Platform, and select an existing project or press the "Create Project" button.
  7. From the project's API Manager, select the Credentials tab in the sidebar.
  8. Create a Browser API Key.
  9. You'll see a modal with an API key. Copy and paste that somewhere.
  10. Now create an OAuth Client ID.
  11. After you complete all the steps and the "content screen," you'll be presented with a modal with your Google Client ID and Client Secret.
  12. You'll need to set three environment variables:

On Windows: Launch cmd.exe and enter the following commands:

setx GOOGLE_API_KEY your_key_goes_here
setx GOOGLE_DEFAULT_CLIENT_ID your_client_id_goes_here
setx GOOGLE_DEFAULT_CLIENT_SECRET your_client_secret_goes_here

On Mac OS X / Linux: Plop these in your ~/.profile file:

export GOOGLE_API_KEY="your_key_goes_here"
export GOOGLE_DEFAULT_CLIENT_ID="your_client_id_goes_here"
export GOOGLE_DEFAULT_CLIENT_SECRET="your_client_secret_goes_here"
  1. Now launch Chromium:

    On Windows: Launch Chromium normally.

    On Mac OS X:

    /Applications/Chromium.app/Contents/MacOS/Chromium
@gsitreble2019
Copy link

gsitreble2019 commented Apr 4, 2021

Edit:

https://groups.google.com/u/0/a/chromium.org/g/google-browser-signin-testaccounts
https://groups.google.com/a/chromium.org/forum/?fromgroups#!forum/chromium-dev
https://console.cloud.google.com/apis/api/chromesync.googleapis.com

These 3 links work for me! Only!
Thanks!

apt-cache policy chromium-browser
chromium-browser:
  Installed: 89.0.4389.90-0ubuntu0.18.04.2
  Candidate: 89.0.4389.90-0ubuntu0.18.04.2
apt-get install chromium-browser

Subscribe to mailing list (as stated in gist 1). Then you just enable Chrome Sync API at https://console.cloud.google.com/apis/library/chromesync.googleapis.com
Now create all the GOOGLE_API_KEY GOOGLE_DEFAULT_CLIENT_ID GOOGLE_DEFAULT_CLIENT_SECRET keys as shown above. I used TV-and-Limited-Input-devices when Creating OAuth client ID. Not sure that matters

In ubuntu edit file:

/etc/chromium-browser/default
Add lines:

##all these are random numbers from a cat typing my keyboard so please do try them in production if you have free time...

GOOGLE_API_KEY=AIzazUdJiNwlR6zYtNd
GOOGLE_DEFAULT_CLIENT_ID=83728372837-wn4AKjPv02YM1x4gv.apps.googleusercontent.com
GOOGLE_DEFAULT_CLIENT_SECRET=EERRN-JtEoGYoqL7xGZ6hhIxbM

export GOOGLE_API_KEY
export GOOGLE_DEFAULT_CLIENT_ID
export GOOGLE_DEFAULT_CLIENT_SECRET

Now either restart laptop or ideally it should source automagically.

Can any bash expert tell me why it did not work for me if I use

###DOES NOT WORK
export GOOGLE_API_KEY=AIzazUdJiNwlR6zYtNd
export GOOGLE_DEFAULT_CLIENT_ID=83728372837-wn4AKjPv02YM1x4gv.apps.googleusercontent.com
export GOOGLE_DEFAULT_CLIENT_SECRET=EERRN-JtEoGYoqL7xGZ6hhIxbM

#but doing it separately like above works fine
  1. https://askubuntu.com/questions/1322559/sync-chromium-with-a-google-account-does-not-work-any-more-solutions
  2. https://arnoldthebat.co.uk/wordpress/2021/02/10/important-update/

@DAC324
Copy link

DAC324 commented Apr 29, 2021

In Arch-based Linux distributions, Chromium and Chromium-Dev are using a special launcher that parses a configuration file for additional options.
It is ~./config/chromium-flags.conf for Chromium, and ~/.config/chromium-dev-flags.conf for Chromium-Dev. For the information discussed here, just insert the following lines into that file:
--user-agent="Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36"
--oauth2-client-id=xxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com
--oauth2-client-secret=xxxxxxxxxxxxxxxxxxx
Of course, replace those xxx by your actual data.
Unfortunately, I did not find an option to insert the API Key there as well, so it looks like in Arch and Manjaro, you will have to amend /etc/environment to include
GOOGLE_API_KEY=xxxxxxxxxxxxxxxxxxx

@IamCarbonMan
Copy link

Sync still isn't working for me. Chromium no longer complains about not having API keys and now has a "turn on sync" button but after clicking it and logging in with Google it takes me back to new tab and nothing has changed.

@bogdan-13
Copy link

bogdan-13 commented May 2, 2021

Sync still isn't working for me. Chromium no longer complains about not having API keys and now has a "turn on sync" button but after clicking it and logging in with Google it takes me back to new tab and nothing has changed.

Signing in to Chromium is restricted
Signing in to Chromium requires an OAuth 2.0 token for authentication. As this OAuth 2.0 token gives access to various Google services that handle user data (e.g. Chrome sync), for security and privacy reasons the generation of this OAuth 2.0 token is restricted. This means that signing in to Chromium is restricted (as the OAuth 2.0 token cannot be generated). In order to sign in to Chromium builds, please add your test account to google-browser-signin-testaccounts@chromium.org (accounts in this group are allowed to get access tokens bypassing the restriction above).

It works ;)

@hariskar
Copy link

hariskar commented May 8, 2021

I want to create OAuth client ID for Chromium on Android. What Application type should I choose when I create the OAuth client ID?
I chose "Web Application" and sync does not work. I have completed all previous steps.
Thank you for guide!

@AkiSakurai
Copy link

I want to create OAuth client ID for Chromium on Android. What Application type should I choose when I create the OAuth client ID?
I chose "Web Application" and sync does not work. I have completed all previous steps.
Thank you for guide!

Android chromium use GoogleAuthUtil to retrieve tokens. It does not use outh client Id specified in args.gn, instead it delegate the process to google play services, which is guarded by whitelisting fingerprint of apps signature. Currently it is restricted to official build only.

@obayit
Copy link

obayit commented Dec 13, 2021

It worked after I did the steps, and then subscribed to the test accounts group. Before subscribing to that groups, it just redirected me to my new tab page after I logged in! chromium forever!

@Kief5555
Copy link

Terminal errors: Cannot turn Sync On for invalid account.

@TheBlindedBoy
Copy link

Did the steps. Just as obayit said just join: test accounts group. Thanks so much everyone.

@AlexeyBalin
Copy link

Thanks, OAuth 2.0 Client IDs with type "TV client" works for me!

@umueller459
Copy link

umueller459 commented Jan 28, 2022

https://groups.google.com/u/0/a/chromium.org/g/google-browser-signin-testaccounts
(For this you cannot see any content. It is OK. Just join - all OK)

https://groups.google.com/a/chromium.org/forum/?fromgroups#!forum/chromium-dev
(Tip: Unsubscribe from emails. You do not need to see those emails)

https://console.cloud.google.com/apis/api/chromesync.googleapis.com
(For this press, Enable button)

Just approve these 3 in the given order. Get the API keys as given below and setup your environment. Just Works...

@rudolfschmidt
Copy link

After putting the variables I can click the sync button but after clicking I get in the console:
[20103:20103:0201/125522.340482:ERROR:dice_turn_sync_on_helper.cc(226)] Cannot turn Sync On for invalid account.
Any idea?

@umueller459
Copy link

umueller459 commented Feb 1, 2022

Cannot turn Sync On for invalid account.

That means you need to click on each of these google links and SUBCRIBE. For the last one ENABLE...

https://groups.google.com/u/0/a/chromium.org/g/google-browser-signin-testaccounts
(For this you cannot see any content. It is OK. Just join - all OK)
https://groups.google.com/a/chromium.org/forum/?fromgroups#!forum/chromium-dev
https://console.cloud.google.com/apis/api/chromesync.googleapis.com

@belr20
Copy link

belr20 commented Feb 18, 2022

This works fine for my BunsenLabs Lithium distro, a derivative from Debian 10 Buster 👌 Many thanks 🙏

@rudolfschmidt
Copy link

rudolfschmidt commented Feb 23, 2022

At https://groups.google.com/u/0/a/chromium.org/g/google-browser-signin-testaccounts I get the note that I cannot see the content because of missing permission and that I have to contact the group admin. Any idea?

Edit:
I created a new config directory and the syn works but how to use my old data to be synced? If I use my current config folder, the sync is not kicked in

@umueller459
Copy link

I get the note that I cannot see the content because of missing permission and that I have to contact the group admin. Any idea?

You will NOT see anything. It is all OK. It is like that (it is just a group to join)...

If I use my current config folder, the sync is not kicked in

Turn off and ON sync. Click on the right side top icon of you name and login. All should work.

@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

@LearningToPi
Copy link

After spending a LOT of time searching the internet I found this thread very helpful but didn't fill in all the blanks for me. I wrote a complete step-by-step tutorial to setup Chromium with chrome-sync on a Radxa Rock5B running Ubuntu 20.04 LTS. https://www.learningtopi.com/sbc/chromium-sync/. Hope this helps anyone else that stumbles onto this thread!

@leandroknorre
Copy link

After spending a LOT of time searching the internet I found this thread very helpful but didn't fill in all the blanks for me. I wrote a complete step-by-step tutorial to setup Chromium with chrome-sync on a Radxa Rock5B running Ubuntu 20.04 LTS. https://www.learningtopi.com/sbc/chromium-sync/. Hope this helps anyone else that stumbles onto this thread!

IT WORKS!! Thank you. I've been able to sync up my Antix22 32-bit chromium

@Uugsx
Copy link

Uugsx commented Mar 30, 2023

After spending a LOT of time searching the internet I found this thread very helpful but didn't fill in all the blanks for me. I wrote a complete step-by-step tutorial to setup Chromium with chrome-sync on a Radxa Rock5B running Ubuntu 20.04 LTS. https://www.learningtopi.com/sbc/chromium-sync/. Hope this helps anyone else that stumbles onto this thread!

IT WORKS!! Thank you. I've been able to sync up my Antix22 32-bit chromium

In LMDE 5, I save variables

GOOGLE_DEFAULT_CLIENT_SECRET=
GOOGLE_DEFAULT_CLIENT_ID=
GOOGLE_API_KEY=

in /home/test/.config/environment.d , file 50-chrome-sync.conf

I restart my PC, but nothing happens, why is this?

it is possible to run with chrome synchronization only from the terminal

export GOOGLE_DEFAULT_CLIENT_SECRET=XXXXXXX
export GOOGLE_DEFAULT_CLIENT_ID=XXXXXXXXXXXX
export GOOGLE_API_KEY=XXXXXXXXXXXX
chromium

help me to understand the reason

@umueller459
Copy link

After spending a LOT of time searching the internet I found this thread very helpful but didn't fill in all the blanks for me. I wrote a complete step-by-step tutorial to setup Chromium with chrome-sync on a Radxa Rock5B running Ubuntu 20.04 LTS. https://www.learningtopi.com/sbc/chromium-sync/. Hope this helps anyone else that stumbles onto this thread!

IT WORKS!! Thank you. I've been able to sync up my Antix22 32-bit chromium

In LMDE 5, I save variables

GOOGLE_DEFAULT_CLIENT_SECRET= GOOGLE_DEFAULT_CLIENT_ID= GOOGLE_API_KEY=

in /home/test/.config/environment.d , file 50-chrome-sync.conf

I restart my PC, but nothing happens, why is this?

it is possible to run with chrome synchronization only from the terminal

export GOOGLE_DEFAULT_CLIENT_SECRET=XXXXXXX export GOOGLE_DEFAULT_CLIENT_ID=XXXXXXXXXXXX export GOOGLE_API_KEY=XXXXXXXXXXXX chromium

help me to understand the reason

Ask LMDE devs how is the SHELL working. In many linux distros, add the values to $HOME/.profile

@Goury
Copy link

Goury commented May 24, 2024

An attempt to add a comment there results in Nginx 403 error.
How awesome.

His suggested method doesn't work on modern GNU systems.
The correct way seems to be ~/.profile.
It works nowadays and is used since some very long time ago.
There's no need to use dysfunctional Pottering's magic when there's a simple and universal solution that actually works.

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