Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting Error :- GooglePlaces API Error: REQUEST_DENIED #42

Open
aanchalkalani opened this issue Aug 23, 2016 · 4 comments
Open

Getting Error :- GooglePlaces API Error: REQUEST_DENIED #42

aanchalkalani opened this issue Aug 23, 2016 · 4 comments

Comments

@aanchalkalani
Copy link

aanchalkalani commented Aug 23, 2016

Hi,

While searching any thing getting error :- GooglePlaces API Error: REQUEST_DENIED

We added our API key properly and follow the below :-

Manual
Simply copy GooglePlacesAutocomplete.swift and GooglePlacesAutocomplete.xib to your project.
Note: Don't forget to add the PoweredByGoogle image to your xcassets.

Thanks,

@RanjitKadam
Copy link

@watsonbox , In swift 3 and ios 10 I am also getting the same error. Previously it used to work fine

@Gladkov-Art
Copy link

The same problem for me.

@Gladkov-Art
Copy link

It seems that I have tracked down the problem. It was related to escaping of optional query parameters. Here is the solution (I have rewritten the origin functions):

  fileprivate class func query(_ parameters: [String: AnyObject]) -> String {
    var components: [(String, String)] = []
    for key in Array(parameters.keys).sorted(by: <) {
        if let value = parameters[key] as? String {
            let escapedValue = escape(value)
            components += [(escape(key), escapedValue)]
        }
    }
    return (components.map{"\($0)=\($1)"} as [String]).joined(separator: "&")
  }

  fileprivate class func escape(_ string: String) -> String {
    var escapedCharacters = CharacterSet.urlQueryAllowed
    escapedCharacters.remove(charactersIn: ":/?&=;+!@#$()',*")
    return string.addingPercentEncoding(withAllowedCharacters: escapedCharacters) ?? ""
  }

@4taras4
Copy link

4taras4 commented May 11, 2017

fileprivate class func query(_ parameters: [String: AnyObject]) -> String {
        var components: [(String, String)] = []
        for key in Array(parameters.keys).sorted(by: <) {
            let value: AnyObject = parameters[key]!
            components += [(escape(key), escape("\(value)"))]
        }
        
        return (components.map{"\($0)=\($1)"} as [String]).joined(separator: "&")
    }


Or like this works too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants