Skip to content

Commit

Permalink
refactor: remove hardcoded google api key (#15478)
Browse files Browse the repository at this point in the history
* refactor: remove hardcoded Google API key

* address changes from review
  • Loading branch information
codebytere committed Oct 31, 2018
1 parent 86064a7 commit b2e1a93
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 29 deletions.
1 change: 0 additions & 1 deletion atom/app/atom_main_delegate.cc
Expand Up @@ -11,7 +11,6 @@
#include "atom/app/atom_content_client.h"
#include "atom/browser/atom_browser_client.h"
#include "atom/browser/relauncher.h"
#include "atom/common/google_api_key.h"
#include "atom/common/options_switches.h"
#include "atom/renderer/atom_renderer_client.h"
#include "atom/renderer/atom_sandboxed_renderer_client.h"
Expand Down
5 changes: 2 additions & 3 deletions atom/browser/atom_browser_client.cc
Expand Up @@ -31,7 +31,6 @@
#include "atom/browser/web_contents_permission_helper.h"
#include "atom/browser/web_contents_preferences.h"
#include "atom/browser/window_list.h"
#include "atom/common/google_api_key.h"
#include "atom/common/options_switches.h"
#include "atom/common/platform_util.h"
#include "base/command_line.h"
Expand Down Expand Up @@ -428,11 +427,11 @@ void AtomBrowserClient::DidCreatePpapiPlugin(content::BrowserPpapiHost* host) {
#endif
}

// attempt to get api key from env
std::string AtomBrowserClient::GetGeolocationApiKey() {
std::unique_ptr<base::Environment> env(base::Environment::Create());
std::string api_key;
if (!env->GetVar("GOOGLE_API_KEY", &api_key))
api_key = GOOGLEAPIS_API_KEY;
env->GetVar("GOOGLE_API_KEY", &api_key);
return api_key;
}

Expand Down
17 changes: 0 additions & 17 deletions atom/common/google_api_key.h

This file was deleted.

10 changes: 3 additions & 7 deletions docs/api/environment-variables.md
Expand Up @@ -48,20 +48,16 @@ Unsupported options are:

### `GOOGLE_API_KEY`

Electron includes a hardcoded API key for making requests to Google's geocoding
webservice. Because this API key is included in every version of Electron, it
often exceeds its usage quota. To work around this, you can supply your own
Google API key in the environment. Place the following code in your main process
You can provide an API key for making requests to Google's geocoding webservice. To do this, place the following code in your main process
file, before opening any browser windows that will make geocoding requests:

```javascript
process.env.GOOGLE_API_KEY = 'YOUR_KEY_HERE'
```

For instructions on how to acquire a Google API key, visit [this page](https://www.chromium.org/developers/how-tos/api-keys).

For instructions on how to acquire a Google API key, visit [this page](https://developers.google.com/maps/documentation/javascript/get-api-key).
By default, a newly generated Google API key may not be allowed to make
geocoding requests. To enable geocoding requests, visit [this page](https://console.developers.google.com/apis/api/geolocation/overview).
geocoding requests. To enable geocoding requests, visit [this page](https://developers.google.com/maps/documentation/geocoding/get-api-key).

### `ELECTRON_NO_ASAR`

Expand Down
1 change: 0 additions & 1 deletion filenames.gni
Expand Up @@ -576,7 +576,6 @@ filenames = {
"atom/common/crash_reporter/win/crash_service_main.h",
"atom/common/draggable_region.cc",
"atom/common/draggable_region.h",
"atom/common/google_api_key.h",
"atom/common/heap_snapshot.cc",
"atom/common/heap_snapshot.h",
"atom/common/key_weak_map.h",
Expand Down

0 comments on commit b2e1a93

Please sign in to comment.