Google Maps API Key visable - View Source

2,103 views
Skip to first unread message

jim

unread,
Jan 3, 2012, 7:19:45 PM1/3/12
to Google Maps JavaScript API v3
I am very new to the API - using the javascript apiin an asp.net app -
need to hide my api key (visable when doing view source on the page) -
any suggetions?

Thanjks

Rossko

unread,
Jan 4, 2012, 5:11:59 AM1/4/12
to Google Maps JavaScript API v3
> I am very new to the API - using the javascript apiin an asp.net app -
> need to hide my api key (visable when doing view source on the page) -

Why do you need to hide it? You can control which domains it is valid
for at Google's API Console
http://code.google.com/apis/maps/documentation/javascript/tutorial.html#Obtaining_Key
so that it is no use to anybody else

jim

unread,
Jan 4, 2012, 10:32:41 AM1/4/12
to Google Maps JavaScript API v3
I know the docs say that - BUT - I am using the same key in a test
environment at work and a test environment at home - different domains
- and they both work.

Anyway - I would like to know how to hide this from view source - I
know it will be an issues if we go to production with a company key.

On Jan 4, 5:11 am, Rossko <ros...@culzean.clara.co.uk> wrote:
> > I am very new to the API - using the javascript apiin an asp.net app -
> > need to hide my api key (visable when doing view source on the page) -
>
> Why do you need to hide it?  You can control which domains it is valid
> for at Google's API Consolehttp://code.google.com/apis/maps/documentation/javascript/tutorial.ht...

Andrew Leach

unread,
Jan 4, 2012, 10:50:46 AM1/4/12
to google-map...@googlegroups.com
On 4 January 2012 15:32, jim <jim.p...@gmail.com> wrote:
> I know the docs say that - BUT - I am using the same key in a test
> environment at work and a test environment at home - different domains
> - and they both work.
>
> Anyway - I would like to know how to hide this from view source - I
> know it will be an issues if we go to production with a company key.

There are issues with keys. Hopefully Thor or Chris or Enoch or Luke
will chime in at some point.

http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/840d1533fbffde2d/e5f468bcfc5d5f41

However, you can't hide the key in the source: the browser needs it to
add to the GET request for the API. You *may* be able to use something
like tinyurl to reduce the entire url to something a little more
covert; but (a) the redirection involved may break it; (b) it's hardly
secure.

Marcelo

unread,
Jan 4, 2012, 10:52:40 AM1/4/12
to Google Maps JavaScript API v3
On Jan 4, 8:32 am, jim <jim.p.ev...@gmail.com> wrote:
>
> Anyway - I would like to know how to hide this from view source - I
> know it will be an issues if we go to production with a company key.

You cannot hide what is sent to the browser. You can obfuscate it, but
any of the people answering questions in this forum will be able to
get it anyway, and so will a lot of other experienced programmers.

--
Marcelo - http://maps.forum.nu
--
Reply all
Reply to author
Forward
0 new messages