I have develop an iPhone Application that have Google Api https://maps.googleapis.com/maps/api/geocode/json?latlng=%f,%f&key=API_KEY
if I have use Public apikey then its working fine but when I generate ristricted api key from google concole then api is not working and give error
{
"error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address 27.109.**.**, with empty referer",
"results" : [],
"status" : "REQUEST_DENIED"
}
I have added valid bundle Id when I generate restricted Api key.
please give me solution Thanks in advance.
You are calling a web service (Geocoding API). Please note that web services support only IP address restriction. The iOS app restriction is not valid for web services, it works only with Google Maps SDK for iOS. You can find information about restrictions supported by each API in this document:
https://developers.google.com/maps/faq#keysystem
In order to use a restricted API key with Geocoding API from iOS app you will need to create your own intermediate server and execute calls to Google from your server. In this case you can protect an API key with IP address of your server. The app will request information from your server and you server will call Google and pass back results.
Related
I'm trying to program geocoding. I created API key, but when I add it into my website code I don't get anything, however when I don't use API everything works well. When I'm sending:
https://maps.googleapis.com/maps/api/geocode/json?address=".$adres."&key=KLUCZ_XXX
I get a response:
Browser API keys cannot have referer restrictions when used with this API.
If I use:
https://maps.googleapis.com/maps/api/geocode/json?address=".$adres"
The result is correct but the number of queries is limited per day.
Key constraint: referrals HTTP (Web) - set to the domain from which conjure inquiry. Interface Google Maps Geocoding API is turned on.
Does the API key has to be activated also somewhere else to work?
It sounds like you may be making the API call server side. I ran into this issue earlier today. Since you've placed a referrer restriction on your API key, it will be limited to executing on the browser with the web service APIs, including the Geocoding API. It didn't work for me even when manually setting the referrer in the request headers. You can find the other web service APIs on this page: https://developers.google.com/maps/web-services/
Important: If you are using any of the web service APIs with an API key that has referer restictions, your requests will fail with the error message: "API keys cannot have referer restrictions when used with this API." You should switch to using a server restriction.
You'll want to create a separate key to use server-side. You can change your restriction from a browser restriction to a server restriction by using IP addresses to restrict access, instead of browser referrers.
See this section in the Maps APIs FAQ on switching key type to a server restricted key: https://developers.google.com/maps/faq#switch-key-type
Alternatively, you can continue using a browser key and geocode client-side (JavaScript), then return the result to the backend via ajax.
If server-side geocoding is not an option, you should use the geocoder from the Google Javascript API. You can set HTTP referer restrictions on that API.
Google itself says to avoid the Non-Javascript Geocoder API for dynamic geocoding:
This service is generally designed for geocoding static
(known in advance) addresses for placement of application content on a
map; this service is not designed to respond in real time to user
input. For dynamic geocoding (for example, within a user interface
element), consult the documentation for the Maps JavaScript API client
geocoder and/or the Google Play services Location APIs.
This issue happens when you set the referrer for the server key to the domain name instead of the IP address, then it will show this message -
API keys with referer restrictions cannot be used with this API
.
For geocode API create a separate API key and restrict that API using IP address.
It worked for me.
I am testing the Google Places API on the Flutter Android app.
When I send a request to the API I get a JSON result with the following error message:
This IP, site or mobile application is not authorized to use this API key.
To build the request, I went to the Google API console and generated my Android API Key based on my application package.
I'm using Google Maps on the app and trying to make a request to the Places API.
I put both Application restrictions and API restrictions in Google API console using package name and SHA1
Without restrictions Places API work but with restrictions it's not working.
I'm fairly new to all this so any help is gratefully received. I have a flutter app that calls the Google Maps API. To call the API I pass it my Google API key and in order to try and make it secure I have set up application restrictions in https://console.cloud.google.com/
The problem is that now when I call the Maps API I get the follwoing error:-
This IP, site or mobile application is not authorized to use this API key
Below is a screenshot of the settings that I have applied. What have I done wrong?
UPDATE: Some more information
The relevant APIs are enabled. The SHA-1 Fingerprint is correct. My app is running in debug mode, the certificate is the debug one. If I unrestrict the API key then everything runs okay.
On the notes of this page, there is a mention that the Geocoding API key should be server-restricted
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 server-restricted
API key, and add the key to your application.
Is the geocoding API only meant to be used on a server type instance?
Can I put the Geocoding API key on a mobile device by bundling it within the app using restriction for android/ios? I'm concerned that I will violate the said "server-restricted API key" clause.
PS. I'm aware that Google API keys can be restricted to android/ios/ip etc.
In order to make Google Maps Web Service requests from a mobile device (without using the Google Maps SDK), you have to use an unrestricted key. Each mobile device has its own IP address and it is not feasible to set IP address restrictions to all the mobile devices that use your app.
Android or iOS API key application restrictions only work for requests made through the Android or iOS SDK.
If you want to use a restricted key for web service requests from mobile devices, you have to use a proxy server that makes the requests on behalf of the mobile app.
I’ve been reading the documentation and it seems that the Geocoding Web Service API is not fit for my use case. There is a “Javascript Google Maps API” that I can use.
It seems that the generated keys in the Google API's console are not working anymore. With different keys (tried it with both server and browser key, however the server key is what I need), generated from different accounts I get constantly the following errors:
Error when using server key:
{
"error_message" : "This site or IP is not authorized to use this API key.",
"results" : [],
"status" : "REQUEST_DENIED"
}
Error when using browser key:
{
"error_message" : "The provided API key is expired.",
"results" : [],
"status" : "REQUEST_DENIED"
}
And these are the enabled services on this account/project: http://upload.uprise.nl/et2j
This is the URL I'm trying: https://maps.googleapis.com/maps/api/geocode/json?address=900+Maple+Avenue%2C+L7S+2J8+Burlington+%28Ontario%29%2C+Canada&oe=utf8&sensor=false&key=mykey
Without the key it is working until I reach my daily limit (which causes the OVER_QUERY_LIMIT status).
Are more people experiencing this?
I have faced same issue... But finally got resolved. Google place services will take 10 minutes to make the services available for new API KEY created. Services will stat working after 10 minutes, till then we get error as "The provided API key is expired."
Geocoding is not one of the services available through the developer console at this time, which is why the key does not work (note that geolocation is not the same as geocoding).
Currently you'd need to use client side geocoding (for example in the JS Maps API) -- or purchase more server side geocoding with a maps for business license in order to increase this quota.
The fact it says the key is expired is misleading, and I'll file a bug for that.
EDIT/UPDATE: The geocoding service is now available through the developer console.
Enable
Google Places API Web Service from google console. It's work for me.
If you're switching from the free API services to a Maps API for Business implementation, you must remove the key parameter from your requests. Google Maps API web services will deny requests made with both a client ID and a key.
https://developers.google.com/maps/documentation/business/webservices/
For me Services has started working after 7 minutes.