Skip to content

Instantly share code, notes, and snippets.

@lopugit
Forked from ezeeyahoo/set-up-chromium-keys.md
Created December 15, 2019 08:31
Show Gist options
  • Save lopugit/65a1c668f4d894b072b2a37f62560e9c to your computer and use it in GitHub Desktop.
Save lopugit/65a1c668f4d894b072b2a37f62560e9c to your computer and use it in GitHub Desktop.
Launch Chromium with API Keys on Mac OS X 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.[Unofficial/Unstable/Latest build] OR Download from https://github.com/macchrome/chromium/releases (stable)
  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 [email protected] 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 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"

On Mac:

It's really simple, safe and secure

Or do same manually:-

  1. mv /Applications/Chromium.app/Contents/MacOS/Chromium /Applications/Chromium.app/Contents/MacOS/Chromium_bin

  2. Write a script and place it inside /Applications/Chromium.app/Contents/MacOS/ with name Chromium, recheck in getinfo once. Use your keys here:-

#!/bin/bash

# Set up environment variables
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"

# Launch Chromium
exec ./Applications/Chromium.app/Contents/MacOS/Chromium_bin "$@"
  1. Give it +x permission chmod +x /Applications/Chromium.app/Contents/MacOS/Chromium
  1. Now launch Chromium:

    On Windows: Launch Chromium normally.

    On Mac OS X:    Launch normally from Launchpad or Spotlight

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