Google URL 缩短器 returns 错误,{"domain"=>"usageLimits", > "reason"=>"ipRefererBlocked

Google URL Shortener returns error, {"domain"=>"usageLimits", > "reason"=>"ipRefererBlocked

我想在 ruby 上使用 google url shortener。 我一直在使用 googl。 在 google 开发者控制台,我有一个 api 密钥。我已经设置了 ip 地址“127.0.0.1”。

然后,我写了如下,但是返回了一个错误。 你能告诉我如何解决这个问题吗?

Googl.shorten('url',"127.0.0.1",my_api_key)

Googl::Error ({"error"=>{"errors"=>[{"domain"=>"usageLimits", "reason"=>"ipRefererBlocked", "message"=>"There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed.", "extendedHelp"=>"https://console.developers.google.com"}], "code"=>403, "message"=>"There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed."}}): app/controllers/products_controller.rb:102:in `create'

在 google 开发者控制台,如果我使 api 键没有指定 ip 地址,它不会 return 错误。但我仍然不确定为什么它在指定 ip 地址时 returns 错误。