1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

「invalid_grant Invalid JWT Signature.」エラーが突然発生したときの対処方法

Last updated at Posted at 2020-01-19

datastoreを絡めたAPIを触っていると、ある日突然以下のようなエラーが発生するようになった。

{
  "error": "invalid_grant",
  "error_description": "Invalid JWT Signature."
}

全く心当たりがなかったので色々調べると、どうやらGOOGLE_APPLICATION_CREDENTIALSに割り当てているサービスアカウントが関係してそうだったので、以下でアカウントを切り替えて動作確認しようとした。

$ gcloud auth activate-service-account --key-file ${service-account-path}

すると最初のエラーと同様のエラーが出力された。

ERROR: (gcloud.auth.activate-service-account) There was a problem refreshing your current auth tokens: invalid_grant: Invalid JWT Signature.

そこでサービスアカウントを生成し直したところ正常に動作することを確認した。

# 割り当ても問題なし
$ gcloud auth activate-service-account --key-file ${new-service-account-path}
Activated service account credentials for: [new-service-account@project-name.iam.gserviceaccount.com]
1
1
1

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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?