Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Places API Key for Android App

I have created an API Key (for Android apps) for my Android Application. It was required by google maps API. But now the same key won't work for Google Places API.

I also tried hitting the browser with the following URL:

https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJN1t_tDeuEmsRUsoyG83frY4&key=my_key

I get:

{
   "error_message" : "This IP, site or mobile application is not authorized to use this API key.",
   "html_attributions" : [],
   "status" : "REQUEST_DENIED"
}

When I googled for an answer, I found this:

https://developers.google.com/places/training/autocomplete-android

What type of API key?

You'll need your own browser or server API key for the Google Places API before you can begin using the Place Autcomplete service. Note that an Android API key will not work for the Place Autocomplete service.

This got me confused as I do not have any URL for a web app, nor any server IP. Therefore I am confused on how to get either a Browser key or a Server key

Could anyone please help me in figuring out what sort of key is needed here? Also if I have to create a Browser key or a Server key, how can I do so?

like image 422
ihsan Avatar asked Jul 11 '14 12:07

ihsan


People also ask

Where do I get Google Places API key Android?

Go to the Google Maps Platform > Credentials page. On the Credentials page, click Create credentials > API key. The API key created dialog displays your newly created API key. Click Close.

Is Google Places API free for Android?

The autocomplete request is available at no charge, and the subsequent Place Details call gets charged based on regular Place Details pricing. A Place Details request generates Data SKUs (Basic, Contact, and/or Atmosphere) – depending on the fields that are specified in the request.

Where can I find the new API key for my App?

The new API key is listed on the Credentials page under API keys. (Remember to restrict the API key before using it in production.) Note: You can use the same API key for your Maps SDK for Android and Places SDK for Android apps. Adding the API key to your app

Can I use the same API key for places SDK for Android?

Note: You can use the same API key for your Maps SDK for Android and Places SDK for Android apps. Add the API key when initializing the Places SDK for Android in your application. Restricting API keys adds security to your application by ensuring only authorized requests are made with your API key.

What is the API_key for Google Maps API?

A key with this name can be used to authenticate to multiple Google Maps-based APIs on the Android platform, including the Maps SDK for Android. For backwards compatibility, the API also supports the name com.google.android.maps.v2.API_KEY. This legacy name allows authentication to the Android Maps API v2 only.

How do I restrict the Places API on Android apps?

Select Android apps. Click + Add package name and fingerprint. Enter your package name and SHA-1 certificate fingerprint. For example: Click Restrict key. Select Places API from Select APIs dropdown. If the Places API is not listed, you need to enable it. To finalize your changes, click Save. List existing keys.


1 Answers

For working with places api generate browser key because for that android key does not work. Had same issue but this solved the problem

like image 171
Suraj Pohwani Avatar answered Oct 10 '22 00:10

Suraj Pohwani