Google API关键问题

我正在开发一个应用程序,我需要从Google Places API中查询地点,并将最近的地方保存到用户的Google帐户(他们通过GIDSignINlogin到应用程序)。 Places API在控制台中被激活,并且它们的关键字是正确的,但是,URL可能有问题,并且我不断收到此错误…

可选([“error_message”:该IP,站点或移动应用程序无权使用此API密钥。从IP地址2607:f598:b349:fd01:94f8:7386:d82c:1b29收到的请求,为空引用者, “:(),”status“:REQUEST_DENIED,”html_attributions“:()])

被调用来查询API的方法,当前经纬度来自位置pipe理器(工作正常)

func saveCurrentLocation() { //API CALL let latString = String(currentLat) let longString = String(currentLong) let apiString = NSString(format: "https://maps.googleapis.com/maps/api/place/search/json?location=%f,%f&radius=500&types=food&sensor=true&key=AIzaSyDH0jNx1WJw0pkCzbc0xaHumDoDAYYWvtk", latString, longString) let url = NSURL(string: apiString as String) let session = NSURLSession.sharedSession() let dataTask = session.dataTaskWithURL(url!) { (data, response, error) -> Void in if let urlContent = data { do { let jsonDictionary = try NSJSONSerialization.JSONObjectWithData(urlContent, options: NSJSONReadingOptions.AllowFragments) as? [String:AnyObject] print(jsonDictionary) } catch { print("JSON error") } } } dataTask.resume() } 

任何人都可以帮忙? 谢谢!

这种types的错误通常出现在您未在Google控制台上启用您的API的情况下。 所以请在控制台上启用Api。