What API Key is Google using when I load the JS script - javascript

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

Related

Google Map API key error "Your site URL to be authorized"

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)

getting error using google maps api : This API project is not authorized to use this API

The google maps request is going to the Google Maps Api (javascript).
But I am getting this error message
And yes the google maps api is enabled and I have generated a key that I am using in my code.
But getting this error "This API project is not authorized to use this API", screenshot below
According to the recent changes announced on June 22, 2016
We now count Google Maps JavaScript API client-side requests towards the daily limit of the associated web service API.*
http://googlegeodevelopers.blogspot.com.es/2016/06/building-for-scale-updates-to-google.html
That means you have to enable Geocoding API in your project if you use geocoding service of Maps JavaScript API. If you use places library, you have to enable Places API and so on.
I am having this problem as well, but only on some pages within my site - on other pages, it works fine. All the pages which use the maps API use it in exactly the same way, via a shared javascript library.
I compared the network calls on pages with and without the error, and they appear to be 100% identical except for the Referrer URL (https://site.url/page/that/works vs. https://site.url/page/that/fails).
I have https://site.url in the "Accept requests from these HTTP referrers" list, and this functionality used to work on all the pages! It stopped working recently, perhaps as recently as this weekend, yesterday, or today.
Are you appending the maps script by hand on your website, or using a plugin? Can you send here your website URL?
Anyway, here it is how to append the API key:
Let's assume that you have the following piece of code
<script async defer src="//maps.googleapis.com/maps/api/js" type="text/javascript"></script>
To append the apy key, you must add ?key=YOUR_API_KEY at the end of the src path, like this:
<script async defer src="//maps.googleapis.com/maps/api/js?key=YOUR_API_KEY" type="text/javascript"></script>
If, instead, your src path already has some appended parameters (for example, "//maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"), just add &key=YOUR_API_KEY at the very end:
"//maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&key=YOUR_API_KEY"
This is how you append the API parameter (obviously, replace YOUR_API_KEY with your API key code).
You can find more information on obtaining a google maps key at https://developers.google.com/maps/documentation/javascript/get-api-key
Your API key should be up and running within 5 minutes. Enjoy!
To make it work
we need to use Google Maps Geocoding Api and Google Maps Javascript Api
I was unfortunately using only the javascript one.
It's working fine now.

Google Maps v3 API key won't work for local testing

I have an API key. It's a "Key for browser apps (with referers). It works fine, but I'm not authorized when I try to use it on my local development server. I use MAMP and my local URL looks like this: http://mysite.dev.
In "Referers" section I have:
mysite.com/*
mysite.dev/*
The production one (.com) works fine, so I'm pretty sure my syntax is correct. But no matter what I try for the local version, I get the authorization error popup from Google telling me:
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
Surely there is a way to get this working! What is it?
UPDATE :
As of June 22, 2016 Google Maps V3 no longer support keyless access (any request that doesn't include an API key).
You can register for the key : https://developers.google.com/maps/documentation/javascript/get-api-key
and add it to your URL :
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY" type="text/javascript"></script>
I have faced a similar issue with my application. I use the url without the client key for testing purposes and add the key before putting the code onto the production server. This is a workaround more than a solution and I am assuming that your usage for local testing will be low.
Testing server
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?sensor=SET_TO_TRUE_OR_FALSE">
</script>
Production Server
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=API_KEY&sensor=SET_TO_TRUE_OR_FALSE">
</script>
URL : https://developers.google.com/maps/documentation/javascript/examples/
If you check the following site and go to the basic map example you will find that the examples do not use a key. This was one of the differences between v2 and v3 of the maps that the key is not mandatory.
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
Keep in mind that omitting the key falls under the free Google Maps API licensing. If you need to track usage, you must supply at least the key. If you need more traffic, you need to supply your client ID (Google Maps for Work).
https://developers.google.com/maps/licensing
As suggested in the official documentation:
Tip: During development and testing, you can register a project for testing purposes in the Google API Console and use a generic, unrestricted API key. When you are ready to move your app or website into production, register a separate project for production, create a browser-restricted API key, and add the key to your application.
You should register a different project and use its unrestricted API for developmental testing.

How to make Youtube Data Search API open for public usage?

Currently, I can use Youtube Data API to search for videos. However, I must be logged in onto my google account. Is it possible to conduct searches without logging in into an arbitrary google account? This way any user can just search without logging in.
I am using Youtube api in javascript
Search is a special case, where users don't have to log in through OAuth2. But you will need to provide your API key to authorize the access uf API usage.
Here's the example. HTML and JS
You'll need an API key so that any searching done through your app can be properly analyzed, routed, etc. If you're using v3 of the data API (which you should now that it's in production), you can easily request a key as you would get access to any google API:
Visit https://code.google.com/apis/console and register your
project (don't forget to give it a project ID)
From that project dashboard, select the Youtube API under the
'Services' tab.
Since you just want to do searching, under the 'API
Access' tab you can create a browser app key (part of the 'Simple
API Access' section). That generated key should be appended to all
REST calls.
If you still need to use v2 of the API for some reason, you can create your key here:
https://code.google.com/apis/youtube/dashboard/gwt/index.html

Google Maps API authentication while forwarding over local network

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/*

Categories