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.

  • Swift - how to add custom fields to markers in Google Maps SDK?
  • myLocationEnabled changing to isMyLocationEnabled on swift when using GoogleMaps
  • How to invoke iPhone Maps for Directions with Current Location as Start Address
  • What is proper way to get ETA (estimated time arrival) from any location to my current location
  • Creating custom info window in swift with the Google maps iOS sdk?
  • Fit entire Google Map in zoom level in Swift project
  • 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.