目次

Google APIの呼び出し時に 'The service searchconsole has thrown an exception. HttpStatusCode is Forbidden.' エラーが発生する

Google Search Console APIの呼び出し時に 'The service searchconsole has thrown an exception. HttpStatusCode is Forbidden.' エラーが発生する現象について紹介します。

現象

Google Search Console APIの呼び出し時に次のエラーが発生します。
エラーメッセージ
Google.GoogleApiException: 'The service searchconsole has thrown an exception. HttpStatusCode is Forbidden. Google Search Console API has not been used in project 000000000000 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/searchconsole.googleapis.com/overview?project=000000000000 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.'

原因

原因はいくつかありますが、サービスアカウントで認証している場合、サービスアカウントがGoogle Search Consoleの利用者に登録されていない可能性があります。
Google Search ConsoleのWebページにアクセスし、設定でサービスアカウントを利用者に追加します。 詳しくはこちらの記事を参照して下さい。
著者
iPentecのメインプログラマー
C#, ASP.NET の開発がメイン、少し前まではDelphiを愛用
掲載日: 2022-05-12
iPentec all rights reserverd.