node-apn icon indicating copy to clipboard operation
node-apn copied to clipboard

Uncaught VError: Failed to generate token: secretOrPrivateKey must be an asymmetric key when using ES256

Open tkafka opened this issue 2 years ago • 3 comments

Hello, I have generated the token for push notifications at Keys section (https://developer.apple.com/account/resources/authkeys/list), enabled Apple Push Notifications service (APNs) there, but when using the generated key (AuthKey_XXXYYYZZZ.p8), I get an error Uncaught VError: Failed to generate token: secretOrPrivateKey must be an asymmetric key when using ES256 from lib/credentials/token/prepare.js:41:13.

I have found that the cause probably is that Apple's generated key is a symmetrical one. Is there a way to convert it to an asymmetrical one, or generate the one that will be accepted?

tkafka avatar Aug 21 '23 14:08 tkafka

Thanks for opening this issue!

I see this issue is closed but I am getting the same error as @tkafka. Any fix or workaround?

innesngunn avatar Sep 05 '23 10:09 innesngunn

I deleted my node_modules folder and reinstalled from npm. No errors anymore.

innesngunn avatar Sep 07 '23 17:09 innesngunn