このページでは、API キーを使用して、API キーを受け付ける Trusted Cloud by S3NS API とサービスにアクセスする方法について説明します。
Trusted Cloud by S3NS API のすべてが API キーによる使用の承認を受け付けるわけではありません。使用するサービスまたは API のドキュメントで、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.
-
Configure the gcloud CLI to use your federated identity.
For more information, see Sign in to the gcloud CLI with your federated identity.
-
Create local authentication credentials for your user account:
gcloud auth application-default login
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
詳細については、 Trusted Cloud 認証ドキュメントのローカル開発環境の ADC の設定をご覧ください。
C++
ローカル開発環境でこのページの C++ サンプルを使用するには、gcloud CLI をインストールして初期化し、ユーザー認証情報を使用してアプリケーションのデフォルト認証情報を設定します。
-
Install the Google Cloud CLI.
-
Configure the gcloud CLI to use your federated identity.
For more information, see Sign in to the gcloud CLI with your federated identity.
-
Create local authentication credentials for your user account:
gcloud auth application-default login
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
詳細については、 Trusted Cloud 認証ドキュメントのローカル開発環境の ADC の設定をご覧ください。
Go
ローカル開発環境でこのページの Go サンプルを使用するには、gcloud CLI をインストールして初期化し、ユーザー認証情報を使用してアプリケーションのデフォルト認証情報を設定します。
-
Install the Google Cloud CLI.
-
Configure the gcloud CLI to use your federated identity.
For more information, see Sign in to the gcloud CLI with your federated identity.
-
Create local authentication credentials for your user account:
gcloud auth application-default login
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
詳細については、 Trusted Cloud 認証ドキュメントのローカル開発環境の ADC の設定をご覧ください。
Node.js
ローカル開発環境でこのページの Node.js サンプルを使用するには、gcloud CLI をインストールして初期化し、ユーザー認証情報を使用してアプリケーションのデフォルト認証情報を設定します。
-
Install the Google Cloud CLI.
-
Configure the gcloud CLI to use your federated identity.
For more information, see Sign in to the gcloud CLI with your federated identity.
-
Create local authentication credentials for your user account:
gcloud auth application-default login
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
詳細については、 Trusted Cloud 認証ドキュメントのローカル開発環境の ADC の設定をご覧ください。
Python
ローカル開発環境でこのページの Python サンプルを使用するには、gcloud CLI をインストールして初期化し、ユーザー認証情報を使用してアプリケーションのデフォルト認証情報を設定します。
-
Install the Google Cloud CLI.
-
Configure the gcloud CLI to use your federated identity.
For more information, see Sign in to the gcloud CLI with your federated identity.
-
Create local authentication credentials for your user account:
gcloud auth application-default login
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
詳細については、 Trusted Cloud 認証ドキュメントのローカル開発環境の ADC の設定をご覧ください。
REST
このページの REST API サンプルをローカル開発環境で使用するには、gcloud CLI に指定した認証情報を使用します。
Install the Google Cloud CLI, and then sign in to the gcloud CLI with your federated identity.
詳細については、 Trusted Cloud 認証ドキュメントの REST を使用して認証するをご覧ください。
REST で API キーを使用する
REST API 呼び出しに API キーを含めるには、x-goog-api-key
HTML ヘッダーを使用します。
HTTP ヘッダーを使用できない場合は、key
クエリ パラメータを使用できます。ただし、この方法では API キーが URL に含まれるため、URL スキャンでキーが公開されます。
クライアント ライブラリで API キーを使用する
アプリケーションで API キーを使用する場合は、保存時と転送時の両方でキーの安全確保に努めてください。API キーが公開されると、アカウントに対して予想外の料金が課される可能性があります。詳細については、API キーの管理に関するベスト プラクティスをご覧ください。
次のステップ
- 認証方法の概要を表示する。
- API Keys API について学習する。