google 地图 url 请求给出消息 "This IP, site or mobile application is not authorized to use this API key"

google maps url request gives msg "This IP, site or mobile application is not authorized to use this API key"

我在为源点和目标点请求 url 时从 google 地图收到此消息错误。有没有人知道这件事。请分享您的经验。

{ "error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address 103.24.99.82, with empty referer",

"routes" : [], "status" : "REQUEST_DENIED"

}

url: https://maps.googleapis.com/maps/api/directions/json?origin=24.878353,67.064308&destination=24.909353,67.085304&sensor=false&avoid=highways&mode=driving&key={key_value_here}

您必须从一个项目调用 google 方向 api,该项目具有与您创建的密钥关联的相同包 ID

可能是IP地址被Google限制了的原因。

您可以按照以下步骤进行纠正:

  1. 转到 Google API 控制台。
  2. Select 您注册时为您创建的项目。
  3. 从 API 键列表中,select 您正在使用的键。
  4. 在“限制”部分,select IP 地址(网络服务器、cron 作业等)。
  5. 在接受来自这些服务器 IP 地址的请求下,输入要从中接受您的密钥的 IP 地址,每行一个。您还可以使用 CIDR 表示法输入子网(例如 192.168.0.0/22)。