web-push-libs/web-push-csharp

403 Forbidden

dorathoto opened this issue · 3 comments

In some cases, I'm having a 403 Forbidden error

When debugging the probe is when I call
webPushClient.SendNotification (pushSubscription, finalMessage, vapidDetails);
Is there any way I can tell why some have this problem?
Does this have to do with the generation of the key and the subject in generation?
Error:

<properties>
  <property key="Objeto EX:">
    <structure type="WebPushException">
      <property key="StatusCode">Forbidden</property>
      <property key="Headers">
        <sequence>
          <item>
            <structure type="KeyValuePair`2">
              <property key="Key">X-Content-Type-Options</property>
              <property key="Value">
                <sequence>
                  <item>nosniff</item>
                </sequence>
              </property>
            </structure>
          </item>
          <item>
            <structure type="KeyValuePair`2">
              <property key="Key">X-Frame-Options</property>
              <property key="Value">
                <sequence>
                  <item>SAMEORIGIN</item>
                </sequence>
              </property>
            </structure>
          </item>
          <item>
            <structure type="KeyValuePair`2">
              <property key="Key">X-Xss-Protection</property>
              <property key="Value">
                <sequence>
                  <item>1; mode=block</item>
                </sequence>
              </property>
            </structure>
          </item>
          <item>
            <structure type="KeyValuePair`2">
              <property key="Key">Date</property>
              <property key="Value">
                <sequence>
                  <item>Tue, 04 Jun 2019 13:14:36 GMT</item>
                </sequence>
              </property>
            </structure>
          </item>
          <item>
            <structure type="KeyValuePair`2">
              <property key="Key">Alt-Svc</property>
              <property key="Value">
                <sequence>
                  <item>quic=":443"; ma=2592000; v="46,44,43,39"</item>
                </sequence>
              </property>
            </structure>
          </item>
        </sequence>
      </property>
      <property key="PushSubscription">
        <structure type="PushSubscription">
          <property key="Endpoint">https://fcm.googleapis.com/fcm/send/e4v4Q1....:AP9M......</property>
          <property key="P256DH">BDEIDL7KZs.......</property>
          <property key="Auth">WZIPE...........</property>
        </structure>
      </property>
      <property key="Message">Received unexpected response code: 403</property>
      <property key="Data" />
      <property key="InnerException" />
      <property key="TargetSite">Void HandleResponse(System.Net.Http.HttpResponseMessage, WebPush.PushSubscription)</property>
      <property key="StackTrace">   at WebPush.WebPushClient.HandleResponse(HttpResponseMessage response, PushSubscription subscription)
   at WebPush.WebPushClient.SendNotification(PushSubscription subscription, String payload, Dictionary`2 options)
   at COI.Nuntius.Services.PushService.EnviaPushNotification(Int32 DeviceId) in PushMensagem.cs:line 52</property>
      <property key="HelpLink" />
      <property key="Source">WebPush</property>
      <property key="HResult">-2146233088</property>
    </structure>
  </property>
  <property key="SetorErro">Nuntius</property>
</properties>

the problem was that the key used to register the device was different from the key used to send.

I have the same error. I confirm to use the same publish key. but still error 403. Note that firefox still works, this problem only occurs on chrome browser.
Is there a workaround?

I have the same as @sonhoenrich trouble.