Документы Google предоставляют несколько советов, чтобы исправить это. https://developers.google.com/calendar/v3/errors#401_invalid_credentials
401: Invalid Credentials
Invalid authorization header. The access token you're using is either expired or invalid.
{
"error": {
"errors": [
{
"domain": "global",
"reason": "authError",
"message": "Invalid Credentials",
"locationType": "header",
"location": "Authorization",
}
],
"code": 401,
"message": "Invalid Credentials"
}
}
Suggested actions:
Get a new access token using the long-lived refresh token.
If this fails, direct the user through the OAuth flow, as described in Authorizing requests with OAuth 2.0.
If you are seeing this for a service account, check that you have successfully completed all the steps in the service account page.
В указанном вами сообщении об ошибке c указано «Требуется вход в систему», поэтому, возможно, ваша проблема связана с потоком OAuth. Однако я вижу, что вы говорите:
Я выполнил все инструкции, создал приложение, сгенерировал необходимые учетные данные.
Если это так, похоже, вы могли бы нужен новый токен доступа.