10

I get an error like so:

    {
   "error_message" : "This API project is not authorized to use this API.",
   "results" : [],
   "status" : "REQUEST_DENIED"
}

whenver I run this: https://maps.googleapis.com/maps/api/geocode/json?address=Winnetka&key=AIzaSyCKyVbBzwtgkyuut7P5mxK9vcOWMygCfp0

In the sample video that I am following, he gets a result like so: enter image description here

Ibanez1408
  • 4,550
  • 10
  • 59
  • 110

5 Answers5

11

in my case i had # in address link input=City Clinical # 89so i had to remove it

Moode Osman
  • 1,715
  • 18
  • 17
  • 2
    Just to clarify. I AM USING AN API KEY and I still got the ERROR because of `#` in my address. After removing `#`, as this answer suggests, I had no problems. – jtorca Oct 22 '20 at 02:03
  • Could you explain, why # cause the problem? – CoderDesu Mar 09 '21 at 14:27
6

You need an API key. Otherwise it won't work.

To get an API Key you have to go to this webpage https://cloud.google.com/maps-platform/#get-started and pick the products you need. Also select or create a project and finally you have to set up a billing account. Unfortunately it isn't for free as far as I know.

Arif Baykara
  • 86
  • 1
  • 3
5

Post Values like below:

  String str_origin = "origin=" + origin.latitude + "," + origin.longitude;
    // Destination of route
    String str_dest = "destination=" + dest.latitude + "," + dest.longitude;

    // Sensor enabled
    String sensor = "sensor=true";
    String mode = "mode=driving";
    String key = "key="+getResources().getString(R.string.google_maps_key);
    // Building the parameters to the web service
    String parameters = str_origin + "&" + str_dest + "&" + sensor + "&" + mode + "&" + key;

    // Output format
    String output = "json";

    // Building the url to the web service
    String url = "https://maps.googleapis.com/maps/api/directions/" + output + "?" + parameters;
murugan mani
  • 375
  • 5
  • 6
2

Read Google's developer page instructions on the Required parameters, might help.

Rahul S Tomar
  • 121
  • 10
  • 2
    I did what it says in the document but still a no go. Please see my edits. – Ibanez1408 Feb 20 '19 at 11:05
  • 1
    @Ibanez1408 you might have to enable few APIs, see the answers [here](https://stackoverflow.com/questions/32994634/this-api-project-is-not-authorized-to-use-this-api-please-ensure-that-this-api). Also, try not to put your API key in here – Rahul S Tomar Feb 21 '19 at 12:20
1

Google states

"As of June 11, 2018, you must enable billing with a credit card and have a valid API key for all of your projects."

https://cloud.google.com/maps-platform/user-guide/?hl=en

and

"You must have a valid API key and a billing account to access our APIs. When you enable billing, you will get $200 free usage every month for Maps, Routes, or Places."

https://cloud.google.com/maps-platform/user-guide/account-changes/?hl=en

Yves
  • 229
  • 2
  • 6