REQUEST_DENIED in responce of Google Places API Request (sensor=true)

I am trying to get places around my location, using Google Places API.

Following is the code, for hitting URL for places search.

  • Clustering Google Maps Markers in iOS
  • CLLocationManager delegate methods are not getting called(google maps is integrated)
  • How to include a button in InfoWindow
  • Alternative for google maps API
  • Exception on API Key of Google Maps API for iOS
  • Forward geocoding doesnt give correct results
  • NSString *URL = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/place/search/json?location=-33.8670522,151.1957362&radius=500&sensor=true&key=0dp-j3dkCU_YUb97RHcbL5shmRrJ5R2y4bYz1Vw"];
    
    NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL:[NSURL URLWithString:URL]
                                                               cachePolicy: NSURLRequestReloadIgnoringLocalCacheData
                                                           timeoutInterval: 4];
    [request setValue:@"application/json" forHTTPHeaderField:@"accept"];
    NSObject *id1 = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];
    

    Which gets me the following response, in JSON Format.

    {
      "html_attributions" : [],
      "results" : [],
      "status" : "REQUEST_DENIED"
    }
    

    On Searching Google Places API, It says, incorrect sensor parameter value is general cause for “REQUEST_DENIED”. But, In my case, I am providing that, too, correct.

    Any Idea where am I going wrong ??

    Again, the APIKey I am using is common for the App to be develope on Android, iPhone and BlackBerry. Is that Valid ? Or, Do I need another APIKey (Specific for my iPhone App)? So, Another question is, Can i use the same key on all three platforms ??

    2 Solutions Collect From Internet About “REQUEST_DENIED in responce of Google Places API Request (sensor=true)”

    I took your URL and substituted a key that I know works, and got the expected results. At first glance I am guessing either your copied/pasted your key incorrectly, or you have not enabled the Places API for the Project this key is associated with in the API Console.

    It’s important to note that each project can have different services enabled – and you must enable the Places API manually for each project you wish to use it with — can you confirm it is enabled in the console and the key is copied accurately?

    This error message can also appear if you are missing required parameters.

    For example, I just had a similar issue using the /autocomplete endpoint of the Places API.

    Sending a request to https://maps.googleapis.com/maps/api/place/autocomplete/json?key=XXXXXXXXXXXXXXXXXX&input=San, I was getting a response like this:

    {
       "predictions" : [],
       "status" : "REQUEST_DENIED"
    }
    

    Even though it looks like a permissions issue (at least to me), it turns out I was simply missing a required sensor parameter.