Jump to content

Recommended Posts

Posted

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?

Posted

Perhaps we're talking about different things here, but isn't the API key for Google Maps included when loading the maps library -- i.e. it has to be visible in the HTML source as-is? :)

Posted

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.

Posted
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

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
×
×
  • Create New...