使用 OAuth2.0 令牌调用 iid.googleapis.com 会给出 MissingIIdToken

问题描述 投票:0回答:1

我在调用此处列出的端点时遇到问题:https://developers.google.com/instance-id/reference/server。回复是:

{"error":"MissingIIdToken"}

我尝试了多次,并验证了 FCM 注册令牌以及不记名令牌是正确的。这就是《失眠》中的样子:

我使用

https://docs.rs/yup-oauth2/latest/yup_oauth2/
生成了范围为 https://www.googleapis.com/auth/firebase.messaging 的不记名令牌。使用此范围/令牌,我可以毫无问题地将 FCM 消息发送到单个设备。

我做错了什么?代币生成在这里(来自fcm_v1):

async fn token(&self) -> Result<String> {
    let scopes = &["https://www.googleapis.com/auth/firebase.messaging"];

    self.authenticator
        .token(scopes)
        .await
        .map_err(|_| Error::Auth)?
        .token()
        .map(|t| t.to_string())
        .ok_or_else(|| Error::Config)
}
firebase oauth-2.0 firebase-cloud-messaging google-oauth
1个回答
0
投票

刷新FCM注册码(卸载并重新安装应用程序)后它就起作用了。我认为这是一个误导性的错误代码。

© www.soinside.com 2019 - 2024. All rights reserved.