Closed skilFullGH closed 5 years ago
In-app purchase. My code works on local, but not does on my backend. What is a problem i did not find yet, but faced with this
Well, make sure your backend runs same npm versions as your testing machine. Run npm install
to update dependencies.
Another thing I'd suggest to do is to add a console.log(err)
to the node_modules/google-play-billing-validator/index.js
line: 40
And post output here, thanks
Auth error:
{ Error: failed to sign JWT, the key is probably invalid
at /usr/src/app/node_modules/google-oauth-jwt/lib/auth.js:117:18
at obtainKey (/usr/src/app/node_modules/google-oauth-jwt/lib/auth.js:134:11)
at Object.exports.encodeJWT (/usr/src/app/node_modules/google-oauth-jwt/lib/auth.js:108:2)
at exports.authenticate (/usr/src/app/node_modules/google-oauth-jwt/lib/auth.js:19:10)
at TokenRequest.TokenRequest.get (/usr/src/app/node_modules/google-oauth-jwt/lib/token-cache.js:75:4)
at TokenCache.get (/usr/src/app/node_modules/google-oauth-jwt/lib/token-cache.js:30:19)
at /usr/src/app/node_modules/google-oauth-jwt/lib/request-jwt.js:41:19
at /usr/src/app/node_modules/google-play-billing-validator/index.js:36:5
at new Promise (<anonymous>)
at Verifier.verify (/usr/src/app/node_modules/google-play-billing-validator/index.js:35:10)
at Verifier.verifyINAPP (/usr/src/app/node_modules/google-play-billing-validator/index.js:14:15)
at ValidationInAppGoogle.validatePurchase (/usr/src/app/dist/src/services/validationInAppGoogle.js:23:51)
at Purchase.verify (/usr/src/app/dist/src/services/purchase.js:200:14)
at Purchase.create (/usr/src/app/dist/src/services/purchase.js:33:37)
inner:
Error: error:0906D06C:PEM routines:PEM_read_bio:no start line
at Sign.sign (internal/crypto/sig.js:83:26)
at /usr/src/app/node_modules/google-oauth-jwt/lib/auth.js:113:76
at obtainKey (/usr/src/app/node_modules/google-oauth-jwt/lib/auth.js:134:11)
at Object.exports.encodeJWT (/usr/src/app/node_modules/google-oauth-jwt/lib/auth.js:108:2)
at exports.authenticate (/usr/src/app/node_modules/google-oauth-jwt/lib/auth.js:19:10)
at TokenRequest.TokenRequest.get (/usr/src/app/node_modules/google-oauth-jwt/lib/token-cache.js:75:4)
at TokenCache.get (/usr/src/app/node_modules/google-oauth-jwt/lib/token-cache.js:30:19)
at /usr/src/app/node_modules/google-oauth-jwt/lib/request-jwt.js:41:19
at /usr/src/app/node_modules/google-play-billing-validator/index.js:36:5
at new Promise (<anonymous>)
at Verifier.verify (/usr/src/app/node_modules/google-play-billing-validator/index.js:35:10)
at Verifier.verifyINAPP (/usr/src/app/node_modules/google-play-billing-validator/index.js:14:15)
at ValidationInAppGoogle.validatePurchase (/usr/src/app/dist/src/services/validationInAppGoogle.js:23:51)
at Purchase.verify (/usr/src/app/dist/src/services/purchase.js:200:14)
at Purchase.create (/usr/src/app/dist/src/services/purchase.js:33:37) }
"err.body" can be undefined
failed to sign JWT, the key is probably invalid
your key for the service account is incorrent. Check your key
Although I tested with the invalid key and the body existed. I will check and update it repo
Ok, thanks!
Was able to reproduce the same error, make sure your private key is the same as in the file you downloaded from Google API Console. ie. Don't delete any \n
or -----BEGIN PRIVATE KEY-----
or somehow modify the key.
The fix is in 2.0.2
. Please update
I tried pass key via environment variable. Now i take key direct from *.json and it works
Probably will be a good idea add some documentation how to add key as an environment variable, also if you don't wanna hard code the key into your code, you can pass keyFile
as an option to the Verifier.
Steps to reproduce? In-app purchases or Subscription?
Thanks