3

I made a taxi booking project that uses google maps api to locate cabs, pickup and drop locations.

The problem is when I request a ride the following error occurs:

This API project is not authorized to use this API

Note that I had enabled all google map api services then regenerate the key and the problem is still exist.

How to solve this?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Rasool Ahmed
  • 175
  • 1
  • 4
  • 13
  • https://stackoverflow.com/questions/32994634/this-api-project-is-not-authorized-to-use-this-api-please-ensure-that-this-api – Sarath Kn Sep 27 '18 at 06:43
  • I already saw this solution, and enabled the geocoding and geolocation api services, but the problem still occurs. – Rasool Ahmed Sep 27 '18 at 06:54

4 Answers4

5

You need to enable the required APIs in the google Developer console : https://console.developers.google.com/

Select your project on the Top Left corner and then click on the "ENABLE API AND SERVICES" button in the dashboard.

Note that you may need to enable more than 1 API (Directions, Geolocating,Geocoding etc) based on your requirement.

Ashwin Valento
  • 878
  • 1
  • 7
  • 14
2

I found the answer,

The problem was in my code at this line:

public void requestDirection() {

        snackbar = Snackbar.make(view, getString(R.string.fare_calculating), Snackbar.LENGTH_INDEFINITE);
        snackbar.show();
        GoogleDirection.withServerKey(getString(R.string.google_api_key))
                .from(origin)
                .to(destination)
                .transportMode(TransportMode.DRIVING)
                .execute(this);

        confirm.setEnabled(false);
    }

R.string.google_api_key's value was feeded by another key from strings.xml. For now, I gave a direct value to withServerKey until I found the the problem with my strings.xml.

public void requestDirection() {

        snackbar = Snackbar.make(view, getString(R.string.fare_calculating), Snackbar.LENGTH_INDEFINITE);
        snackbar.show();
        GoogleDirection.withServerKey("[api key]")//getString(R.string.google_api_key))
                .from(origin)
                .to(destination)
                .transportMode(TransportMode.DRIVING)
                .execute(this);

        confirm.setEnabled(false);
    }
Umair
  • 6,366
  • 15
  • 42
  • 50
Rasool Ahmed
  • 175
  • 1
  • 4
  • 13
1

If you think you have enabled all, Then you may missed changing your manifest.xml file like :

        <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="@string/google_maps_key" />
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" /> 

Add these tags under application tag

Zaid Mirza
  • 3,540
  • 2
  • 24
  • 40
1

To resolve this issue if you hit polyline Api:

https://console.developers.google.com/google/maps-apis/apis/directions-backend.googleapis.com/metrics?project=light-router-266008

Need to enable the APIs:

  1. GeoLocation API
  2. Directions API
Juri Noga
  • 4,363
  • 7
  • 38
  • 51
safal bhatia
  • 195
  • 1
  • 5