我正在使用我的网络应用程序中的 userEvents.write 方法。我发送了一个如下所示的 JSON 请求,其中包含从gcloud auth application-default print-access-token
命令获取的 Authorization 标头。
{
"eventType": "detail-page-view",
"visitorId": "xxxxxxxxxx.xxxxxxxxxxxx",
"eventTime": "2021-03-06T09:13:58+09:00",
"experimentIds": [
"Gie-xxxxxxxxxxxxxxxxxxxxxxxx"
],
"userInfo": {
"userId": "",
"ipAddress": "xxx.xxx.xxx.xxx",
"userAgent": "Mozilla/5.0 (Linux; Android 11; Pixel 4a (5G)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.181 Mobile Safari/537.36",
"directUserRequest": false
},
"uri": "https://xxxxx.net/aaaaaa/item/196160",
"referrerUri": "https://xxxxxxxx.net/item/196160",
"productDetails": [
{
"product": {
"id": "196160"
}
}
]
}
请求网址是这样的。
https://retail.googleapis.com/v2/projects/{PROJECT_NUMBER}/locations/global/catalogs/default_catalog/userEvents:write
在大多数情况下,它进展顺利。但是,有时会在下面返回错误。
{
"error": {
"code": 401,
"message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.googl
e.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED"
}
}
此错误在应用程序重启后不再出现,几天后再次出现。为什么会出现这个错误?我该如何解决?