【发布时间】:2022-08-13 01:15:45
【问题描述】:
我正在尝试创建一个非常简单的 Web 应用程序,它可以通过 Firebase Cloud Messaging 发送和接收消息(包括推送通知)。我想尝试测试接收从 Google API Explorer 发送的测试消息的能力。但是,我遇到了一个奇怪的错误,因为来自the relevant API URL 的任何 API 调用都会返回以下错误:
{
\"error\": {
\"code\": 401,
\"message\": \"Auth error from APNS or Web Push Service\",
\"status\": \"UNAUTHENTICATED\",
\"details\": [
{
\"@type\": \"type.googleapis.com/google.firebase.fcm.v1.FcmError\",
\"errorCode\": \"THIRD_PARTY_AUTH_ERROR\"
}
]
}
}
作为参考,这是我要发送的消息:
{
\"message\": {
\"token\": \"[FCM_TOKEN]\",
\"notification\": {
\"title\": \"New Notification\",
\"body\": \"Sample Text\"
}
}
}
我还注意到,当我在消息中添加\"validate_only\": true 时,错误消失并且发送请求成功(尽管这没有帮助,因为这会禁用实际发送消息)。
我很难过,因为弹出的提示表明我的 OAuth2 凭据无效,尽管我保留了 OAuth2 凭据选项并通过授权弹出窗口提供我的凭据。
标签: firebase-cloud-messaging google-apis-explorer