LoginSignup
5
2

More than 3 years have passed since last update.

Google Cloud Vision API をPHPから使用する場合に出るエラーの対処

Posted at

Google Cloud Vision API のドキュメント「クライアント ライブラリ」( https://cloud.google.com/vision/docs/libraries?hl=ja ) の手順でPHPから実行して次のようなエラーが出る場合、

Fatal error: Uncaught DomainException: Could not load the default credentials. Browse to https://developers.google.com/accounts/docs/application-default-credentials for more information in /path/vendor/google/auth/src/ApplicationDefaultCredentials.php:168

行頭に次を追加する。

putenv("GOOGLE_APPLICATION_CREDENTIALS=キー生成時のJSONファイルのパス");

上記の他に発生するエラーの対処方法
・次でインストールしたクライアントライブラリのファイルに実行権限がない場合は実行権限を付与する

composer require google/cloud-vision

・Google Cloud Vision API から次のレスポンスでエラーになる場合、サーバーの時刻がNTPと同期していない可能性がある。

"error": "invalid_grant"
5
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
2