問題
google-api-clientを使用しGoogleのSpreadSheetのクライアントをscalaで作ったが、アクセス時に403になった。ハマったのでメモ
com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
"code" : 403,
"errors" : [ {
"domain" : "global",
"message" : "The caller does not have permission",
"reason" : "forbidden"
} ],
"message" : "The caller does not have permission",
"status" : "PERMISSION_DENIED"
}
原因と解決
今回service accountを使用してアクセスしようとしたが、アクセスしたいファイルに当該service accountのアクセス権限がなかったが原因。
- google sheet編集画面の右上の「共有」ボタンを押して出るダイアログに、service accountのメアドを入力。
- 送信ボタンで権限設定が完了する