Skip to content

Setting up your API key

Mike North edited this page Feb 7, 2018 · 1 revision

The final exercises in this workshop depend on the google places API, and you'll need to generate a free API key in order to use it. It'll take about one minute to set this up.

The Steps

1) Rename apikeys.js.default

mv apikeys.js.default apikeys.js

Don't worry about putting private data here. It won't be committed to git

2) Generate a new API Key

Go to the API key generation page and click the "Get a Key" button

3) Create a new Google Places project, or choose an existing one

screen shot 2018-02-07 at 12 36 23 pm

4) Click "Next" to generate the key (this can take 60 seconds or more)

screen shot 2018-02-07 at 12 35 57 pm

5) Open ./apikeys.js and paste your key into the correct place

module.exports = {
  //google: `${'<PASTE YOUR API KEY HERE>' || process.env.GOOGLE_API_KEY}`
  google: `${"you-can't-see-my-key-hahahaha" || process.env.GOOGLE_API_KEY}`
};

6) Test your locally-proxied google places API

Start up the autocomplete-1 project

npm start autocomplete-1

And then then when visiting this url http://localhost:3000/maps/api/place/autocomplete/json?types=establishment&input=coffee

You should see a JSON response containing data about coffee shops