I know that we need to use a unique API key to access the Google Geocoding API.I am using the Rails Geocoder Gem in my application and found out that it uses the Google Geocoding API.I was unable to find any configuration files that define the API keys to access the Google API.How does the Geocoder gem access the Google API's.
Asked
Active
Viewed 2,986 times
1 Answers
4
Geocoder.configure(
:lookup => :google_premier,
:api_key => [ 'GOOGLE_CRYPTO_KEY', 'GOOGLE_CLIENT_ID', 'GOOGLE_CHANNEL' ],
:timeout => 5,
:units => :km,
)
https://github.com/alexreisner/geocoder
Here is one more link : http://hankstoever.com/posts/11-Pro-Tips-for-Using-Geocoder-with-Rails
under Some common configuration options are:
You should look into this answer : Does Geocoder gem work with google API key?
It says:
Geocoder supports Google api keys for Google Premier accounts only.
But you can use the Client-Side framework to do that, instead of putting it on the server
https://developers.google.com/maps/articles/geocodestrat
I wrote something like that a few days back in ruby, if it helps :
require 'net/http'
require "resolv-replace.rb"
require 'json'
url = URI("https://maps.googleapis.com/maps/api/geocode/json")
puts "enter country code"
c_code = gets
puts "enter zip code "
zip = gets
url.query= URI.encode_www_form({ address: "#{c_code.chomp}+#{zip.chomp}" })
res = Net::HTTP::get_response(url)
json_data = res.body if res.is_a?(Net::HTTPSuccess)
data = JSON.parse(json_data)
p data

Community
- 1
- 1

argentum47
- 2,385
- 1
- 18
- 20
-
Hey, what's the up-to-date way to generate credentials for Google now that everything is going through the Google API cloud platform ? Do we need a `Service account key` ? I can find a private key and a client ID but what about the "Google Channel" ? – Cyril Duchon-Doris Sep 26 '18 at 21:26
-
@CyrilDuchon-Doris I am sorry but I haven't dealt with this in some time. You might need to ask another question or try googling. This is why I try to avoid picking up code that involve 3rd party API integrations. – argentum47 Mar 24 '20 at 04:09