Amazon SNS:"Platform credentials are invalid" 重新输入之前有效的 GCM API 密钥

Amazon SNS: "Platform credentials are invalid" when re-entering a GCM API key that previously worked

自今年 4 月以来,我们一直在使用 Amazon SNS 发送 Android 推送通知。

推送没有问题,但是在云控制台中从来没有任何调用云消息传递的记录API(似乎很奇怪?)。

今天我为静态地图服务(不相关)创建了一个新的 API 密钥,并重命名了我们的 Cloud Messaging API 密钥(只是名称,密钥是相同的)。从这一点开始,没有发送任何推送,并且尝试在 AWS 中创建一个新的平台应用程序(或更新现有的应用程序)导致:

Invalid parameter: Attributes Reason: Platform credentials are invalid (Service: AmazonSNS; Status Code: 400; Error Code: InvalidParameter; Request ID:)

我还尝试使用导致未授权 (401) 的密钥手动调用 https://gcm-http.googleapis.com/gcm/send 端点。

有趣的是,我可以使用我今天创建的密钥调用上述端点,但是它们在 MismatchSenderId 上失败。

我在 API 管理器中看不到 Cloud Console 之前的很多选项(服务器/浏览器密钥等)?

API GCM 的密钥管理已移至 Firebase 控制台。 您可以创建一个新的 Firebase 项目(或导入一个现有的云项目),您应该为云消息传递获取一个新的服务器密钥。

查看更新后的文档:
https://developers.google.com/cloud-messaging/android/client#create-an-api-project
和堆栈溢出问题:

如果还有问题请联系:
https://firebase.google.com/support/contact/troubleshooting

对于那些开始一个新项目并想知道为什么它仍然无效的人,请确保将应用程序 Key restriction 设置为 Android apps。在我的例子中,它只设置为 None 并且当我切换到 Android 应用程序时,它在更新后 5 到 10 分钟后工作。您需要添加包名称和 SHA-1 证书指纹。

我在创建 Amazon SNS 平台应用程序时遇到了同样的错误:

Invalid parameter: Attributes Reason: Platform credentials are invalid (Service: AmazonSNS; Status Code: 400; Error Code: InvalidParameter; Request ID:)

按照 Diego 的建议联系 Firebase 支持人员后,这是我从 Google 那里得到的回复:

Hope you're doing well and thanks for reaching out to us.

I'm not really familiar with Amazon SNS and looks like their integration is still with GCM, not FCM. If your app implementation is still GCM, then you need to migrate with FCM in order to use the server key in the console. See the instructions here.

Also, Firebase has upgraded the server keys to a new version. We'd recommend to use the server key instead of the legacy server key.

I hope this helps. Let me know if you have any other concerns. Thank you.

这表示我们必须更改我们的应用程序代码。通过创建一个新的 firebase 项目并将旧服务器密钥与 Amazon SNS 结合使用,我们能够在组织中为另一个应用程序工作。

在某个时候我们肯定会升级到使用 FCM,但目前我们的最后期限很紧。

更新: 所以最后对我们有用的是在 Project Settings --> Cloud Messaging 下使用 'Server Key' 。该应用程序仍然使用 GCM 实现。 Amazon SNS 对此密钥很满意,并生成了一个 GCM 平台推送应用程序。推动工作! 仍然对为什么 'Legacy Server Key' 对一个应用程序不起作用但对另一个应用程序没问题感到困惑。但我不会再深入研究了。

对于那些在 2017 年面临此问题的人,这里有一个提示:

1 - 转到您的 firebase 控制台 (https://console.firebase.google.com/) 单击您的项目(您要将其用于推送通知)

2 - 单击项目名称右侧的 "three dots",然后单击 "Settings"

3 - 单击 header 选项卡上的 "CLOUD MESSAGING"

4 - 复制 "Server Key"(这个比你的 API 键大)

5 - 粘贴到 "Create platform application"

的 AWS 表单的 "API Key" 输入

PS:请注意,这仅对 GCM 推送通知有效。