Jump to content

Googlemap API Keys


opalepatrick
 Share

Recommended Posts

I am looking to hide a googlemap api key from general source code. The first suggestions were to use an environmental variable, then because that doesn't hide the info to then encrypt it. Others have suggested using a config file. (Can I put an array in the config file?) 

What do you guys do to hide API keys from general source code like this?

Link to comment
Share on other sites

There are various different maps api's, so it might not be the one for the javascript map. 

On topic: You can store the key in any place you can exclude from source control, which is readable by php. The most common ones are probably .env files/ENV variables, or a config-something.php, which you include in your main config.php.

Link to comment
Share on other sites

1 hour ago, opalepatrick said:

I am looking to hide a googlemap api key from general source code. The first suggestions were to use an environmental variable, then because that doesn't hide the info to then encrypt it. Others have suggested using a config file. (Can I put an array in the config file?) 

What do you guys do to hide API keys from general source code like this?

You don't have to hide it. In your Google Console Panel just add the domain name URL with wild card or only certain url addresses for that API.

  • Like 4
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...