订阅Firebase主题时为什么会得到PERMISSION_DENIED

时间:2019-07-04 06:27:14

标签: .net firebase firebase-cloud-messaging

我正在致电Firebase以使用主题订阅

https://iid.googleapis.com/iid/v1:batchAdd

所示

https://developers.google.com/instance-id/reference/server

唯一记录的错误是

NOT_FOUND — The registration token has been deleted or the app has been uninstalled.
INVALID_ARGUMENT — The registration token provided is not valid for the Sender ID.
INTERNAL — The backend server failed for unknown reasons. Retry the request.
TOO_MANY_TOPICS — Excessive number of topics per app instance.

此代码可以正常工作数月,并且未更改。但是由于某种原因,我现在看到此错误返回

PERMISSION_DENIED

谁能解释 a)为什么我应该收到未记录的错误,并且 b)该错误实际上表示什么?

谢谢

            // This is the send part of the POST



    string m_FirebaseServerKey  = "<firebase server key for project goes here>";
    string m_url            = "https://iid.googleapis.com/iid/v1:batchAdd";
    m_RegistrationToken         = new string[] { appIID };
            m_Topic             = topic;

    var request = WebRequest.Create(m_url);
            // Add headers from parameters
            request.Method = "POST";
            request.ContentType = "application/json";
            request.Headers["Authorization"] = "key=" + m_FirebaseServerKey ;

            var RequestData = new
            {
                to = "/topics/" + m_Topic,
                registration_tokens = m_RegistrationToken
            };

            // serialise
            string SerializedRequest = SerializeContent(RequestData);

            // send request
            var stream = await request.GetRequestStreamAsync();
            using (var writer = new StreamWriter(stream))
            {
                writer.Write(SerializedRequest);
                writer.Flush();
                writer.Dispose();
            }

0 个答案:

没有答案