Need to get Google Map V3 API work in .net application with purchased ClientID.
The application is using WebBrowser Control to load html into documentText and the Url is 'about:blank'. The problem is I can't put about:blank into authorized URLs list in google map console. Also I can't host html as it needs a lot of data from database. It must be in application.
Can anyone help me how to use google map clientID in application without an url or url = localhost? Is there any way to trick web browser control to use localhost as url but use html in code? Because I can add localhost into white list. Thanks a lot
Well, you can use the OAuth 2.0 instead of a Public API access key; however if you have to Public API access, you should use the Key for server applications, and set it to accept all IP by setting the IP to 0.0.0.0/0.
Related
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.com/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
I 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.com/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.com/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.com accepts all sites ending in google.com, such as https://developers.google.com.
Note: file:// referers need a special representation to be added to the key restriction. The file:// 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 enabling file:// referers, it is recommended you regularly check your usage, to make sure it matches your expectations.
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.com/maps/api/js?key=YOUR_API_KEY&callback=initMap"></script>
(source: https://developers.google.com/maps/documentation/javascript/get-api-key#restrict_key)
I am loading the google maps/places JS API in my web app like this in my web/Ionic mobile app.
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?libraries=places,geometry"></script>
I am not providing an API key in that URL. What api key is google using? If different users use the web-app, will it use a seperate API key for each user? and therefore each user will have a limit on the requests as opposed to the entire app having the limit?
This is the angular directive using the API. It doesn't have a key defined in it.
https://github.com/kuhnza/angular-google-places-autocomplete
Thanks
What api key is google using? If different users use the web-app, will it use a seperate API key for each user?
No, Google API is not requires key. But key gives very useful information (read the link below). Key is unique for each app you use (if you register it in console). More detailed information can be found at Google Developer Console and at page: https://developers.google.com/maps/documentation/javascript/get-api-key
And therefore each user will have a limit on the requests as opposed to the entire app having the limit?
About limits in Maps Google wrote here:
https://developers.google.com/maps/documentation/javascript/usage
I would like to be able to set the mode of travel when sending a request to the google javascript directions API i.e. train or bus. It requires an API key to be included when setting this option. I have an API key but what other settings do I need to change to make it work?
Do I need to add a specific website to the developer console?
and is the key included in the request itself or can it be included in the src part of the javascript with the maps URL? I've tried both options and it's not working.
https://developers.google.com/maps/documentation/javascript/directions?hl=en
Need to get Google Map V3 API work in my application with purchased ClientID.
The application is using WebBrowser Control to load html into documentText and the Url is 'about:blank'. The problem is I can't put about:blank into authorized URLs list in google map console. Also I can't host html as it needs a lot of data from database. It must be in application. Can anyone help me how to use google map clientID in application? Thanks a lot.
Error: This page was unable to display a Google Maps element. This URL
is not authorized to use the provided Google Maps Client ID. Error
Code: UnauthorizedURLForClientIdMapError
Got support from google. To use Client ID this way, they actually have to manually add 'about:blank' into white list.
about:blank is not a URL, it is in some sense the absence or a URL. In fact, loading the API from about:blank does not send a referer header, and window.location in about:blank is empty.
What this means is that you cannot restrict your client id to a specific URL whitelist if you intend to use the API in this way. This would, however, mean that your client id could be used from any host.
I'm using fiddler to forward my local webserver over our local network to test on mobile devices etc.
static function OnBeforeRequest(oSession: Session) {
if (oSession.host.toLowerCase() == "192.168.1.100:8888") oSession.host="localhost:8020";
}
This works fine, except I can't get google maps to authenticate properly with my API key, the dreaded message:
Google has disabled use of the Maps API for this application. The
provided key is not a valid Google API Key, or it is not authorized
for the Google Maps Javascript API v3 on this site. If you are the
owner of this application, you can learn about obtaining a valid key
here:
https://developers.google.com/maps/documentation/javascript/tutorial#api_key
I know the maps api is working on my local machine since I've added "localhost" to the allowed referrers section on the google api console.
I have tried adding my global ip to this list, localhost:8888, localhost:8020 etc. to no avail.
Is there a good way to track which referrer google is picking up so I can add it to my 'allowed' list? I've tried 'document.referrer' in JS, but that returns blank both on local(maps working), and local network remote access (through fiddler, maps not working).
I'm not using PHP, so something in JS would be ideal; I assume this is possible since the google maps API is added as javascript!
Any help would be appreciated, Cheers.
I tried alert(location.host), and it just returned my local ip + port (192.168.1.100:8888)
I was able to actually solve this by changing how the google api accesses my API key.
I was including the key in my JS call on my html page, this is apparently no longer necessary and when I removed it, it worked across LAN.
It now reads:
<script src="https://maps.googleapis.com/maps/api/js?v=3&sensor=false">
Note, all I needed in my Google API referrers section was what I had beforehand:
http://localhost/*