APNs InvalidProviderToken: Check Your .p8 Key
- APNs
- Push
- Expo
- Troubleshooting
APNs returns 403 InvalidProviderToken when the key you signed the request with is not an Apple Push Notification service key for your team. We hit this in one of our own apps: the key ID in the server's settings belonged to an App Store Connect API key, and every send failed until we swapped in a real APNs key. The two files look the same, so one test request is the quickest way to tell them apart.
Who sees this error
The error comes from Apple, so you see it when your server talks to APNs directly: a Supabase Edge Function, a Convex action or your own backend. If you send through the Expo push service, Expo holds the push key. Expo's FAQ says revoking that key makes notifications fail to arrive, and the fix is to add a new push key with eas credentials.
Why the two keys get mixed up
An App Store Connect API key and an APNs key both download as AuthKey_<Key ID>.p8, and both are used to sign a short-lived ES256 token. A .p8 file only holds a private key. It doesn't say what the key may do, so Apple decides that on its server when it checks your signature.
Test the key with one request
Sign a provider token with the .p8, then send a push to a made-up device token. Apple checks your token before it looks at the device, so the status code tells you whether Apple accepts the key. Save this as apns-probe.mjs and run it with the key file, the Key ID, your Team ID and your bundle ID:
// node apns-probe.mjs AuthKey_ABC123DEFG.p8 ABC123DEFG TEAMID1234 com.example.app
import { createPrivateKey, sign, randomBytes } from 'node:crypto';
import { readFileSync } from 'node:fs';
import { execFileSync } from 'node:child_process';
const [p8, keyId, teamId, bundleId] = process.argv.slice(2);
const b64 = (x) => Buffer.from(x).toString('base64url');
const head = b64(JSON.stringify({ alg: 'ES256', kid: keyId }));
const claims = b64(JSON.stringify({ iss: teamId, iat: Math.floor(Date.now() / 1000) }));
const sig = sign('sha256', Buffer.from(`${head}.${claims}`), {
key: createPrivateKey(readFileSync(p8)),
dsaEncoding: 'ieee-p1363', // JWT wants raw r||s, not DER
});
const jwt = `${head}.${claims}.${sig.toString('base64url')}`;
// Node's fetch doesn't speak HTTP/2 to APNs, so let curl send it.
const out = execFileSync('curl', [
'-s', '--http2', '-i', '-X', 'POST',
'-H', `authorization: bearer ${jwt}`,
'-H', `apns-topic: ${bundleId}`,
'-H', 'apns-push-type: alert',
'-d', '{"aps":{"alert":"probe"}}',
`https://api.sandbox.push.apple.com/3/device/${randomBytes(32).toString('hex')}`, // made-up device token
]).toString();
console.log(out.split('\r\n')[0]); // HTTP/2 400 = key accepted, HTTP/2 403 = not an APNs key
console.log(out.split('\r\n\r\n').pop());
Read the first line it prints:
- 400 with
BadDeviceToken: Apple accepted your signature and rejected the fake device token. The key works. Apple's older APNs guide shows this same 400 response. - 403 with
InvalidProviderToken: Apple does not accept this key for this Team ID and Key ID. It is not an APNs key, or the IDs don't match it.
We ran the script on November 25, 2026 with a throwaway key generated on the spot, which Apple has never seen. Apple's sandbox server answered HTTP/2 403 and {"reason":"InvalidProviderToken"}. In our app on October 16, 2026, we used the same signal: a fake 64-character hex token, where a 400 BadDeviceToken in the logs meant Apple had accepted the key.
Fix it
- In your Apple Developer account, open Certificates, Identifiers & Profiles, then Keys, and create a key with Apple Push Notifications service turned on.
- Download the .p8 once. Apple lets you download it a single time.
- Store the file's Key ID, your Team ID and the key contents in your backend's secrets, not in the app or the repo.
- Run the probe again. A
400 BadDeviceTokenmeans Apple accepts the key. - Send a real push to a real device token from a TestFlight or App Store build.
Also check that the token's iss is your Team ID and its kid is the Key ID printed in the file name. A mismatch gets the same 403.
If you send through Expo instead
You don't sign anything yourself. Run eas credentials, pick iOS and your build profile, and check that a push key is listed. Expo's FAQ gives the same command for an expired or revoked key. Our push notifications guide walks through both paths, and the launch checklist lists where push fits before you submit.
Where AppSetUpKit fits
AppSetUpKit does not send pushes for you. Its convex-push-setup.sh explains which of Apple's .p8 keys is the APNs key, so the mix-up above doesn't start. The probe in this article is not one of the kit's files, and you can use it without buying anything.
Sources, checked November 25, 2026: Expo push notifications FAQ and Apple: Communicating with APNs. The 403 result is our own test.
More guides
Expo App Store Launch Checklist (2026)
Every step between a finished Expo app and Submit to App Review, in order, with the Apple rule or Expo doc behind each one. Checked against Apple's and Expo's documentation on November 3, 2026.
AppSetUpKit vs Expo Boilerplates: Free and Paid Starters Compared (2026)
Boilerplates give you app code, while AppSetUpKit sets up the accounts around it. We compare the free Expo starters with four paid ones (prices as listed on November 3, 2026) and say when a free option is enough.