Google Places rejection iOS

30 Views Asked by At

I am in the middle of developing an iOS app where there is a request to Google places and the results are displayed. Here is the code for fetching the information:

func fetchPlaceDetails(placeId: String) {
    let apiKey = "My Google API KEY"
    let urlString = "https://maps.googleapis.com/maps/api/place/details/json?placeid=\(placeId)&key=\(apiKey)"
    guard let url = URL(string: urlString) else {
        self.errorMessage = "Invalid URL"
        return
    }
}

I have set placeid somewhere else.

The error I get back from Google is this:

"error_message": "This IP, site or mobile application is not authorized to use this API key. Request received from IP address [IP address], with empty referer" "status": "REQUEST_DENIED"

On the console side I get a (4xx) error.

Things I have tried:

  1. Making a new API key
  2. Hardcoding the placeID and the API key into the request
  3. Using the same API key to display a map in the same app (this worked for the map but not for the places request)
  4. Restricting the API to just the PlacesAPI
  5. Unrestricting the key at all
  6. I have Google Places enabled in the API Key
  7. I am using package dependencies (8.3.0)

Right now I have the rawJSON data being displayed on the screen. The error above is what is returned. I would like the rawJSON from the request to be displayed.

0

There are 0 best solutions below