ここにある api サンプルを使用しています。
実行gcloud config listすると、デフォルトのプロジェクトが次のように表示されますproject = multichoice-insights
コードの重要な抜粋は、デフォルトの資格情報を取得していることを示しています。
credentials = GoogleCredentials.get_application_default().create_scoped(
['https://www.googleapis.com/auth/cloud-platform'],
)
ただし、API を使用しようとすると、次のエラー メッセージが表示されます。
googleapiclient.errors.HttpError: <HttpError 403 when requesting
https://language.googleapis.com/v1beta1/documents:analyzeSentiment?
alt=json returned "Google Cloud Natural Language API has not been used
in project google.com:cloudsdktool before or it is disabled. Enable it
by visiting
https://console.developers.google.com/apis/api/language.googleapis.com/over
view?project=google.com:cloudsdktool then retry. If you enabled this
API recently, wait a few minutes for the action to propagate to our
systems and retry.">
これは、プロジェクトが使用したことを示していると思います:project=google.com:cloudsdktool
これを に変更するにはどうすればよいproject-nameですか?
コンソールでこの API を有効にしました。