Google CloudのThis API project is not authorized to use this APIエラーが分からない
Q&A
Closed
Google CloudのThis API project is not authorized to use this APIエラーが分からない
Google CloudでAPIキー取得したため、レスポンスが取得できるか確かめたいのですが、うまくいきません。
解決方法を教えて下さい。
発生している問題・エラー
{
"error_message" : "This API project is not authorized to use this API.",
"html_attributions" : [],
"results" : [],
"status" : "REQUEST_DENIED"
}
実行したコード(cmd)
curl -L -X GET "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=37.7937,-122.3965&radius=500&type=restaurant&key=APIキー"
実行したコード(Python)
import requests
API_KEY = "APIキー"
BASE_URL = "https://maps.googleapis.com/maps/api/place/nearbysearch/json"
location = "35.6895,139.6917" # 東京の緯度と経度
radius = 5000 # 検索半径(メートル)
keyword = "コンビニ" # 検索キーワード
def test_places_api():
params = {
"key": API_KEY,
"location": location,
"radius": radius,
"keyword": keyword
}
response = requests.get(BASE_URL, params=params)
data = response.json()
print("APIレスポンス:", data)
test_places_api()
自分で試したこと
検索エンジンで「This API project is not authorized to use this API.」と検索しましたが、
以下のように制限解除する方法しか見つかりませんでした。
https://qiita.com/yoshiwo/items/0b4a84d2413a87218139
Google Maps Platform/鍵と認証情報/API キー/鍵を表示します
上記でAPI キー取得してまして、キーを制限しないにしてます。(Places API(New)は許可済み)
因みに、Google Cloudは入ったばかりなので無料トライアル中ではあります。