kimo26
kimo26

Reputation: 47

My google maps api key is not functioning in python although it works in swift

I use an API key that I got from google maps in my swift project and it works perfectly. When I tried it on python it just gives me an error message. The code that I used and the error message I received are down below.

I enter image description herealready went on the Google cloud platform to get an api key for: - places api - map javascript api - Geolocation api - Geocoding api

Also with this api key I was not successful.

gmaps = googlemaps.Client(key='api-key')
geocode_result = gmaps.geocode('1600 Amphitheatre Parkway, Mountain View, CA')

I expect to get the location's id but I'm receiving: "googlemaps.exceptions.ApiError: REQUEST_DENIED (This API project is not authorized to use this API.)"

Upvotes: 1

Views: 2766

Answers (1)

necklace
necklace

Reputation: 61

Is it possible that you are mixing up your IOS API Key with the API key for Web Services? I see there are at least two different 'Get an API Key' articles:

One for Web Services: https://developers.google.com/maps/documentation/geocoding/get-api-key

And one for IOS : https://developers.google.com/maps/documentation/ios-sdk/get-api-key

And if so, the solution is:

  • The Python googlemaps library requires the Web Services API Key, and trying to use the IOS API Key will not work.

Sometimes Google will show an API as enabled, but it's actually not enabled. Try disabling and re-enabling the Web Services API key.

Another gotcha is that you might need to enable the Directions API as well.

Upvotes: 1

Related Questions