Skip to content

Instantly share code, notes, and snippets.

@cvan
Last active May 24, 2024 12:05
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
@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