Google Sheets API returns "401 - Unauthorized error"

I’m trying to append rows to a Google Sheet using the native API, I have correctly configured the OAuth 2.0, It works correctly with static input but when I try to make it dynamic It’s not working returning the error message “401 - Unauthorized error”.

{
  "error": {
    "code": 401,
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "domain": "googleapis.com",
        "metadata": {
          "method": "google.apps.sheets.v4.SpreadsheetsService.AppendValues",
          "service": "sheets.googleapis.com"
        },
        "reason": "CREDENTIALS_MISSING"
      }
    ],
    "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
    "status": "UNAUTHENTICATED"
  }
}