이 페이지에서는 API 키를 사용하여 API 키를 허용하는 Google Cloud API 및 서비스에 액세스하는 방법을 설명합니다.
일부 Google Cloud API는 사용을 승인하기 위해 API 키를 허용하지 않습니다. 사용하려는 서비스나 API에 대한 문서를 검토하여 API 키 허용 여부를 확인합니다.
API 키 제한을 포함하여 API 키를 만들고 관리하는 방법에 대한 자세한 내용은 API 키 관리를 참조하세요.
Google Maps Platform에서 API 키를 사용하는 방법은 Google Maps Platform 문서를 참조하세요. API 키 API에 대한 자세한 내용은 API 키 API 문서를 참조하세요.시작하기 전에
Select the tab for how you plan to use the samples on this page:
C#
로컬 개발 환경에서 이 페이지의 .NET 샘플을 사용하려면 gcloud CLI를 설치 및 초기화한 다음 사용자 인증 정보로 애플리케이션 기본 사용자 인증 정보를 설정하세요.
- Install the Google Cloud CLI.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
자세한 내용은 Google Cloud 인증 문서의 로컬 개발 환경의 ADC 설정을 참고하세요.
C++
로컬 개발 환경에서 이 페이지의 C++ 샘플을 사용하려면 gcloud CLI를 설치 및 초기화한 다음 사용자 인증 정보로 애플리케이션 기본 사용자 인증 정보를 설정하세요.
- Install the Google Cloud CLI.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
자세한 내용은 Google Cloud 인증 문서의 로컬 개발 환경의 ADC 설정을 참고하세요.
Go
로컬 개발 환경에서 이 페이지의 Go 샘플을 사용하려면 gcloud CLI를 설치 및 초기화한 다음 사용자 인증 정보로 애플리케이션 기본 사용자 인증 정보를 설정하세요.
- Install the Google Cloud CLI.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
자세한 내용은 Google Cloud 인증 문서의 로컬 개발 환경의 ADC 설정을 참고하세요.
Node.js
로컬 개발 환경에서 이 페이지의 Node.js 샘플을 사용하려면 gcloud CLI를 설치 및 초기화한 다음 사용자 인증 정보로 애플리케이션 기본 사용자 인증 정보를 설정하세요.
- Install the Google Cloud CLI.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
자세한 내용은 Google Cloud 인증 문서의 로컬 개발 환경의 ADC 설정을 참고하세요.
Python
로컬 개발 환경에서 이 페이지의 Python 샘플을 사용하려면 gcloud CLI를 설치 및 초기화한 다음 사용자 인증 정보로 애플리케이션 기본 사용자 인증 정보를 설정하세요.
- Install the Google Cloud CLI.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
자세한 내용은 Google Cloud 인증 문서의 로컬 개발 환경의 ADC 설정을 참고하세요.
REST
로컬 개발 환경에서 이 페이지의 REST API 샘플을 사용하려면 gcloud CLI에 제공한 사용자 인증 정보를 사용합니다.
Install the Google Cloud CLI, then initialize it by running the following command:
gcloud init
자세한 내용은 Google Cloud 인증 문서의 REST 사용을 위한 인증을 참고하세요.
REST에 API 키 사용
REST API 호출에 API 키를 포함하려면 다음 예와 같이 x-goog-api-key
HTML 헤더를 사용하세요.
curl -X POST \ -H "X-goog-api-key: API_KEY" \ -H "Content-Type: application/json; charset=utf-8" \ -d @request.json \ "https://translation.googleapis.com/language/translate/v2"
HTTP 헤더를 사용할 수 없는 경우 key
쿼리 매개변수를 사용할 수 있습니다.
그러나 이 방법은 URL에 API 키를 포함하므로 URL 검사를 통해 키가 도난당할 수 있습니다.
다음 예에서는 documents.analyzeEntities
의 Cloud Natural Language API 요청에 key
쿼리 매개변수를 사용하는 방법을 보여줍니다.
API_KEY
를 API 키의 키 문자열로 바꿉니다.
POST https://language.googleapis.com/v1/documents:analyzeEntities?key=API_KEY
클라이언트 라이브러리에 API 키 사용
이 예에서는 API 키를 허용하는 Cloud Natural Language API를 사용하여 API 키를 라이브러리에 제공하는 방법을 보여줍니다.
C#
이 샘플을 실행하려면 Natural Language 클라이언트 라이브러리를 설치해야 합니다.
C++
이 샘플을 실행하려면 Natural Language 클라이언트 라이브러리를 설치해야 합니다.
Go
이 샘플을 실행하려면 Natural Language 클라이언트 라이브러리를 설치해야 합니다.
Node.js
이 샘플을 실행하려면 Natural Language 클라이언트 라이브러리를 설치해야 합니다.
Python
이 샘플을 실행하려면 Natural Language 클라이언트 라이브러리를 설치해야 합니다.
애플리케이션에서 API 키를 사용하는 경우 저장 및 전송 중에 안전하게 보호되도록 해야 합니다. API 키를 공개적으로 노출하면 계정에 예상치 않은 비용이 부과될 수 있습니다. 자세한 내용은 API 키 관리 권장사항을 참조하세요.
다음 단계
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-02-21(UTC)