I have searched many links and read documents related to google api key, but every time I am getting the only error of Your site URL to be authorized
I am creating a PhoneGap hybrid application where I am not sure if which URL I have to pass to google api key referrer so I am stuck here
What I am using for google script is:
<script src=";key=MY_API_KEY&sensor=false" type="text/javascript"></script>
Updated
I have already created Browse Key using google console but now What I have to pass in referrer link ( ? ) while I am creating a cordova application
I have searched many links and read documents related to google api key, but every time I am getting the only error of Your site URL to be authorized
I am creating a PhoneGap hybrid application where I am not sure if which URL I have to pass to google api key referrer so I am stuck here
What I am using for google script is:
<script src="https://maps.googleapis./maps/api/js?v=3&key=MY_API_KEY&sensor=false" type="text/javascript"></script>
Updated
I have already created Browse Key using google console but now What I have to pass in referrer link ( ? ) while I am creating a cordova application
Share Improve this question edited Jun 23, 2016 at 9:19 Kirankumar Dafda asked Jun 23, 2016 at 9:06 Kirankumar DafdaKirankumar Dafda 2,3845 gold badges31 silver badges59 bronze badges4 Answers
Reset to default 3I Dont know if this will help anyone but I spent a good hour trying to figure out this problem and ended up realizing I had the wrong API enabled. You need Google Maps JavaScript API enabled.Also sometimes you need to specify https.
1.Leave it blank 2.You need to enable the google maps api for your project.
You need to enable the google maps api for your project.
if your API key have no limitation and it still not work - trying to add
signed_in=true
to url. It helps for me.
This error means that the current URL loading the Maps JavaScript API has not been added to the list of allowed referrers. Please check the referrer settings of your API key in the Cloud Console. (source: https://developers.google./maps/documentation/javascript/error-messages#referer-not-allowed-map-error)
Go to the Google Cloud credentials page to add your website url: https://console.cloud.google./projectselector2/google/maps-apis/credentials
Select the API key that you want to set a restriction on. The API key property page appears.
Under Key restrictions, set the following restrictions:
- Application restrictions:
- To accept requests from the list of website that you supply, select HTTP referrers (web sites) from the list of Application restrictions.
- Specify one or more referrer web sites. For example,
*.google.
accepts all sites ending ingoogle.
, such ashttps://developers.google.
. Note: file:// referers need a special representation to be added to the key restriction. Thefile://
part should be replaced with__file_url__
before being added to the key restriction. For example,file:///path/to/
should be formatted as__file_url__//path/to/*
. After enablingfile:// referers
, it is remended you regularly check your usage, to make sure it matches your expectations.
- Application restrictions:
Save your changes
You must include an API key with every Maps JavaScript API request. In the following example, replace YOUR_API_KEY with your API key.
<script async defer src="https://maps.googleapis./maps/api/js?key=YOUR_API_KEY&callback=initMap"></script>
(source: https://developers.google./maps/documentation/javascript/get-api-key#restrict_key)