[Error] Google Places API : This IP, site or mobile application is not authorized to use this API key 해결

haehyunlee·2023년 7월 20일
post-thumbnail

에러

Google Places API에 주변 장소 JSON 데이터를 요청하는 코드.
원화는 결과가 안나와서 통신 부분을 디버깅 해보니 아래와 같은 JSON 파일이 수신되는 게 보인다.

{ "error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address {개인IP주소}, with empty referer",   
"html_attributions" : [],   
"results" : [],   
"status" : "REQUEST_DENIED" }

원래라면 results 값에 각 장소(JSONObject)의 배열(JSONArray)가 들어 있어야 하는데, 데이터는 없고 에러 메시지만 출력된다.

"This IP, site or mobile application is not authorized to use this API key. Request received from IP address {개인IP주소}, with empty referer"

접속을 시도하는 IP, 사이트, 모바일 앱이 해당 API 키를 사용하도록 허용되지 않았다는 뜻.

해결

  1. Google Cloud Console 사이트 접속
    API 및 서비스 > 사용 설정된 API 및 서비스

  2. 사용자 인증 정보 > > API키 수정

  3. 애플리케이션 제한사항 설정을 없음으로 바꿔준 뒤 설정을 저장한다.

  4. 앱을 재실행해보면 JSON 데이터가 제대로 받아지는 걸 볼 수 있다.

profile
안드로이드 개발자

0개의 댓글