web-push-libs / web-push-csharp

Web Push library for C#
Mozilla Public License 2.0
429 stars 108 forks source link

UnauthorizedRegistration (400) #38

Closed tmontney closed 6 years ago

tmontney commented 6 years ago
            Dim vapidDetails As New WebPush.VapidDetails("mailto:myemail@domain.com", My.Settings.PushPublicKey, My.Settings.PushPrivateKey)

            Dim Serializer As New Web.Script.Serialization.JavaScriptSerializer
            Dim subscrpObj As Dictionary(Of String, Object) = Serializer.DeserializeObject(Context.Properties("REGISTRATIONBLOB"))

            Dim Keys As Dictionary(Of String, Object) = subscrpObj("subscription")("keys")

            Dim Endpoint As String = subscrpObj("subscription")("endpoint")
            Dim p265dh As String = Keys("p256dh")
            Dim Auth As String = Keys("auth")

            Dim subscrp As New WebPush.PushSubscription(Endpoint, p265dh, Auth)

            Dim push As New WebPush.WebPushClient
            push.SendNotification(subscrp, "", vapidDetails)

Payload used:

{"subscription":{"endpoint":"https://fcm.googleapis.com/fcm/send/cVZGX8otWpE:APA91bFSgTN2vcviHTOgGA66pAAxPLZbMdQS5hPKvEyBfTV5aIEN...","expirationTime":null,"keys":{"p256dh":"BHZfAmES5nxERWtcwf-h...=","auth":"OUab3C..."}}}

I've read in some documentation TTL is a required value, but I'm not seeing it here. Also, I don't know why Subject is needed. What is the email/URL used for?

Used this in conjunction: https://serviceworke.rs/push-simple.html

tmontney commented 6 years ago

I was re-generating public/private keys at each start (which I usually accounted for). Decided to make static, and clear my site data. Once I did that, whatever was going on cleared up.