Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS sending push with APNs Auth Key: suddenly "403 Forbidden: {"reason":"InvalidProviderToken"}"

I'm sending my push notifications with an APNs Auth Key ("never expires") which worked well until suddenly I get

403 Forbidden: {"reason":"InvalidProviderToken"}

as a response when sending push notifications. What could be the reason for this when it worked once and suddenly it doesn't without having an expiration date? In the meantime it worked again for some pushes, but now I get the error again... Did anyone else experience this?

EDIT

Not sure but it seems as if this only happens on the Ubuntu server, not on my local (OS X) machine...

like image 339
swalkner Avatar asked Mar 02 '17 07:03

swalkner


3 Answers

I've seen this in a couple of circumstances:

  1. Resubmitting expired provider tokens seems to get the token blacklisted and results in subsequent InvalidProviderToken rejections rather than ExpiredProviderToken rejections. Check you logs for token expiry messages. Check your system clock to make sure that you're not generating tokens with skewed timestamps.

  2. Submitting to invalid topics will invalidate all provider tokens on the connection (even previously valid ones). Only submit to topics that the key is bound to and only use one key per connection.

like image 59
teppic Avatar answered Nov 12 '22 10:11

teppic


we have exactly the same problem when sending pushes to different team ids using the same connection. The steps to reproduce are:

  • Open a connection to APNS and use the same connection to:

  • Send a token based push to topic com.companyA.xxx of team id 1234: APNS accepts and delivers the push successfully.

  • Send a token based push to topic io.companyB.xxx of team id 5678: APNS responds HTTP 400 BadRequest The device token does not match the specified topic
  • Send again a token based push to topic io.companyB.xxx of team id 5678: APNS responds HTTP 403 Forbidden: the provider token is not valid or the token signature could not be verified.

After this it becomes impossible to send any push and the connection has to be closed and reopened.

The workaround we ended up doing is to open one connection per team id. The APNS documentation does not mention anything like that so I do consider this as a bug and I opened a bug report.

like image 9
Jan Avatar answered Nov 12 '22 10:11

Jan


For me, there was an issue with bad configuration. I was using the wrong Team ID. Please make sure that all configuration is correct before you look into any other solutions.

like image 2
Rajat Jain Avatar answered Nov 12 '22 10:11

Rajat Jain