google-maps-services-js icon indicating copy to clipboard operation
google-maps-services-js copied to clipboard

API Key isn't getting recognized

Open theIYD opened this issue 8 years ago • 4 comments

Problem Description I have included the API key as an environment variable in a .env file. Using this npm library, i am importing the KEY into my app.js file. But the geocode method, is not able to produce an output and says Missing either a valid API key, or a client ID and secret.

Another problem

I am using the RequestHandle interface to obtain a Promise instead of using a callback. The promise takes a little while or does not get returned at times while getting the lat & lng from an address.

theIYD avatar Mar 09 '18 03:03 theIYD

Are you sure the environment variable is working? Did you try to log it on output or debug it somehow? Can you provide that part of the code?

juffalow avatar Mar 27 '18 08:03 juffalow

Can't reproduce this, please re-open if you're able to provide more detail.

stephenmcd avatar May 21 '18 01:05 stephenmcd

I have the same problem with APIKEY, but i'm using firebase lib and everything was working until now... the code i written was very simple to getTokens and variable with redux to connect everything.

Can't find variable: APIKEY

misc.js:20:7 loadModuleImplementation require.js:291:12 index.js:4 loadModuleImplementation require.js:291:12 App.js:5 loadModuleImplementation require.js:291:12 index.js:1 loadModuleImplementation require.js:291:12 guardedLoadModule require.js:179:45 global code :0

can any body help?

Julio-andre avatar Nov 12 '18 10:11 Julio-andre

I am having the same issue. I'm including my API key in my script which is being executed in Google Cloud Firestore as a triggered cloud function on a document update.

const googleMapsClient = require('@google/maps').createClient({
  key: 'my API key here',
  Promise: Promise
});

  googleMapsClient.geocode({address: $address}).asPromise()
    .then((response) => {
      console.log(response.json.results);
      return response.json.results;
    })
    .catch((err) => {
      console.log(err);
  });

The function logs in Firebase read "Missing either a valid API key, or a client ID and secret". But it's clearly defined in the script. Any thoughts?

blackbeario avatar Sep 23 '19 05:09 blackbeario