Skip to content

Instantly share code, notes, and snippets.

Forked from cvan/
Last active June 9, 2022 07:40
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save KhashayarDanesh/c79fe2d4aaf98f193522c3e05a6667c9 to your computer and use it in GitHub Desktop.
Launch Chromium with API Keys on Linux, macOS and Windows

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 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 replace_with_the_string_the_cat_typed
    setx GOOGLE_DEFAULT_CLIENT_ID replace_with_the_string_the_cat_typed
    setx GOOGLE_DEFAULT_CLIENT_SECRET replace_with_the_string_the_cat_typed
  • On Linux: Plop these in your ~/.profile file:

    export GOOGLE_API_KEY="replace_with_the_string_the_cat_typed"
    export GOOGLE_DEFAULT_CLIENT_ID="replace_with_the_string_the_cat_typed"
    export GOOGLE_DEFAULT_CLIENT_SECRET="replace_with_the_string_the_cat_typed"

    see this for more information on API Keys here and on ArchLinux Wiki in general for more info on chromium


    Don't forget to replace the variable values discovered here, which definitely a cat typed on their computer and do absolutely work in production

  • On macOS: Keep in mind that you'd normally open your applications with aqua/finder/spotlight, and that in macOS your shell global vars aren't passed to applications not executed via shell, therefore, in case you want global variables that are inherited in every application run via the GUI, you should inject them to the service manager (launchd) and from there, every application executed after this injection, will inherit the variables from the service manager,

    To add the necessary environment variables to launchd, run the following line in your terminal:

    vim ~/Library/LaunchAgents/chromium.envvars.plist

    Then paste these lines in the file and save:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
        <plist version="1.0">


    Don't forget to replace the variable values discovered here, which definitely a cat typed on their computer and do absolutely work in production

    Then run the following lines to load, enable and run the launchd LaunchAgent:

    launchctl load -w ~/Library/LaunchAgents/chromium.envvars.plist
    launchctl print gui/$UID/chromium.envvars.envvars
  1. Now launch Chromium:

    On Windows: Launch Chromium normally.

    On macOS/Linux: Launch Chromium normally.

Copy link

Wow this is cool !!

Copy link

KhashayarDanesh commented Jun 9, 2022

Wow this is cool !!

@pouyakary I think it had a problem and then it was either resolved or given up on quickly and went back to chrome hell, where your data is stolen and MacBook battery is embezzled.

I will retry this, get back to you and update it here as well.

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